ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int('007'), int('-0_7'), int('0_1'), int('00'))
  1. A. 7 -7 1 1
  2. B. 7 -7 1 0
  3. C. 7 -7 0 0
  4. D. 7 -7 10 0

Correct answer: B. 7 -7 1 0

Leading zeros are allowed in a string passed to int, and a single underscore between digits is ignored. The sign stays in front, so '-0_7' is -7.

More Python Programming questions

Exams that ask this topic