ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int('0' + '9' * 3) + 1, int('9' * 3 + '0') + 1)
  1. A. 1000 9991
  2. B. 999 9991
  3. C. 1000 9990
  4. D. 1000 1000

Correct answer: A. 1000 9991

A leading zero does not change the value, so '0999' is 999 and adding one gives 1000. Appending a zero multiplies by ten, giving 9990, and the extra one makes 9991.

More Python Programming questions

Exams that ask this topic