ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(len(str(int('7' * 4300))))
try:
    int('7' * 4301)
except ValueError:
    print('no')
  1. A. 4300 yes
  2. B. 4300 no
  3. C. 4300 4301
  4. D. 4301 no

Correct answer: B. 4300 no

The int-string limit applies to both directions. An int with 4300 digits converts fine, so the first line is 4300. A 4301-digit decimal string raises ValueError when parsed.

More Python Programming questions

Exams that ask this topic