ProgrammingHardProduct-company MCQ pattern

Which statement about converting a string to an int in Python 3.13 is correct?

  1. A. int() has no digit limit for any input
  2. B. int() raises ValueError for a string with more than 4300 digits unless the limit is changed
  3. C. int() raises OverflowError for any string longer than 20 digits
  4. D. int() silently truncates the result to 64 bits

Correct answer: B. int() raises ValueError for a string with more than 4300 digits unless the limit is changed

Since Python 3.11 the conversion between int and str is capped at 4300 digits by default, which protects against slow conversions. The limit can be changed with sys.set_int_max_str_digits.

More Python Programming questions

Exams that ask this topic