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)))- A. 4300 / parsed / 11
- B. 5000 / ValueError / 11
- C. 4300 / ValueError / 10
- 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
- What is printed? python import math print(math.isclose(0.1 + 0.2, 0.3), math.isclose(1e-12, 0), math.isclose(1e-12, 0, abstol=1e-9))
- What is printed? python print(int('١٢٣') + 1, 'ß'.upper(), 'Dž'.lower(), len('ß'.upper()))
- What is printed? python total = 0.0 for in range(10): total += 0.1 print(total, total == 1.0, sum([0.1] 10) == 1.0)
- Which of these is the best way to build a string from n pieces in CPython, and why?
- A program makes 10^5 membership checks of the form x in visited, where visited holds 10^5 items. Which statement is correct?
- What is printed? python def cnt(a, k): p, l, res = 1, 0, 0 for r, x in enumerate(a): p = x while l <= r and p >= k: p //= a[l] l += 1 res…