ProgrammingHardProduct-company MCQ pattern
Which statement about converting a string to an int in Python 3.13 is correct?
- A. int() has no digit limit for any input
- B. int() raises ValueError for a string with more than 4300 digits unless the limit is changed
- C. int() raises OverflowError for any string longer than 20 digits
- 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
- What relative and absolute tolerances does math.isclose use by default?
- Which key sorts records by score descending and then by name ascending, using one stable sort?
- What is the largest float that is less than 1.0 in Python, as printed by repr?
- What is printed? python print(3 // 2 2 + 3 % 2, -3 // 2 2 + -3 % 2)
- What is printed? python print('%s and %r' % ('a', 'a'))
- What is printed? python print('-'.join(map(str, range(3, 0, -1))))