ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(int('0' * 5 + '7') + int('  -3  '), len(str(int('9' * 50) + 1)))
  1. A. 10 50
  2. B. 4 51
  3. C. 4 50
  4. D. 3 51

Correct answer: B. 4 51

int() accepts leading zeros in base 10 and surrounding whitespace. 7 + (-3) = 4. The number 99...9 (50 nines) plus 1 is 10^50, which has 51 digits.

More Python Programming questions

Exams that ask this topic