ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
import sys
print(sys.get_int_max_str_digits())
try:
    s = str(10 ** 4300)
except ValueError:
    print("too long")
  1. A. 4300 none
  2. B. 4300 too long
  3. C. 4300 4301
  4. D. 4301 too long

Correct answer: B. 4300 too long

Since Python 3.11 str() of an int with more than 4300 digits raises ValueError. 10**4300 has 4301 digits, so the limit is hit. Only int-to-str and str-to-int conversions are limited; arithmetic is not.

More Python Programming questions

Exams that ask this topic