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)
  1. A. False OverflowError
  2. B. False int too large to convert to float
  3. C. True int too large to convert to float
  4. 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

Exams that ask this topic