ProgrammingVery hardJEE Main · CAT placement

What is printed?

What is printed?
try:
    s = str(10 ** 4301)
    print(len(s))
except ValueError:
    print('too many digits')
  1. A. 4302
  2. B. 4301
  3. C. too many digits
  4. D. OverflowError

Correct answer: C. too many digits

Since Python 3.11, converting an int with more than 4300 digits to a string raises ValueError by default. 10**4301 has 4302 digits, so the except branch runs.

More Python Programming questions

Exams that ask this topic