ProgrammingVery hardJEE Main · CAT placement
What is printed?
What is printed?
try:
s = str(10 ** 4301)
print(len(s))
except ValueError:
print('too many digits')- A. 4302
- B. 4301
- C. too many digits
- D. OverflowError
Correct answer: C. too many digits
Since Python 3.11, converting an int with more than 4300 digits to a string raises ValueError by default. 10**4301 has 4302 digits, so the except branch runs.
More Python Programming questions
- What is printed? python print(' xt'.strip() == 'x', 'atb'.expandtabs(4), len('atb'.expandtabs(4)), 'abrncd'.splitlines())
- What is printed? python print('²'.isdigit(), '²'.isdecimal(), '²'.isnumeric(), '٥'.isdecimal())
- What is printed? python print(len('é'.encode('utf-8')), len('é'.encode('utf-16-le')), len('a€'.encode()), b'xc3xa9'.decode())
- What is printed? python print(f"{12:>{5}}|{3.14159:.{2}f}|{'ab':^6}")
- What is printed? python x = 12 print(x & -x, x ^ (x - 1), (x & (x - 1)) == 0, -x & x == x & -x)
- What is printed? python print((-5).tobytes(2, 'big', signed=True).hex(), int.frombytes(b'xffxfb', 'big', signed=True)…