ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(10 ** 309 > float('inf'), end=' ')
try:
float(10 ** 309)
except OverflowError as e:
print(e)- A. False OverflowError
- B. False int too large to convert to float
- C. True int too large to convert to float
- D. False inf
Correct answer: B. False int too large to convert to float
A Python int of any size is smaller than infinity, so the comparison is False. Converting an int too large for a double raises OverflowError, and the message is the one shown.
More Python Programming questions
- What is printed? python from collections import Counter d = {'a': 1, 'b': 2} v = d.values() d['c'] = 3 print(len(v), list(v))
- What is printed? python print(frozenset([1, 2]) == {1, 2}, {frozenset([1]): 'x'}[frozenset([1])])
- What is printed? python a = [1, 2, 3] r = a.reverse() print(r, a)
- What is printed? python t = (1) u = (1,) print(type(t).name, type(u).name, len(u))
- What is printed? python try: print(1.0 // 0.0) except ZeroDivisionError as e: print(e)
- What is printed? python print(int('0x1A', 16), int('1A', 16), int('0x1A', 0))