ProgrammingVery hardProduct-company MCQ pattern

Which three lines are printed?

Which three lines are printed?
import sys
print(sys.get_int_max_str_digits())
try:
    int('1' * 5000)
    print('parsed')
except ValueError:
    print('ValueError')
print(len(str(10**4000 // 10**3990)))
  1. A. 4300 / parsed / 11
  2. B. 5000 / ValueError / 11
  3. C. 4300 / ValueError / 10
  4. D. 4300 / ValueError / 11

Correct answer: D. 4300 / ValueError / 11

Since Python 3.11, converting an int with more than 4300 digits to or from a string raises ValueError by default, a guard against quadratic-time attacks. 10**4000 // 10**3990 is 10**10, which has 11 digits.

More Python Programming questions

Exams that ask this topic