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")- A. 4300 none
- B. 4300 too long
- C. 4300 4301
- 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
- What is printed? python print(len(str(2 1000 5 1000)))
- What is printed? python rows = [(2, 'b'), (1, 'z'), (2, 'a'), (1, 'y')] print(sorted(rows, key=lambda t: (-t[0], t[1])))
- What is printed? python print(sorted(['bb', 'a', 'cc', 'd', 'ee'], key=len, reverse=True))
- What is printed? python import bisect a = [1, 2, 2, 2, 3] print(bisect.bisectleft(a, 2), bisect.bisectright(a, 2), bisect.bisectright(a…
- What is printed? python import bisect print(bisect.bisectleft([5, 4, 3], 4))
- What is printed? python import bisect print(bisect.bisectleft([(1, 'a'), (3, 'b'), (5, 'c')], 3, key=lambda t: t[0]))