ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(float('1e400'), -float('1e400'))
  1. A. 1e400 -1e400
  2. B. OverflowError
  3. C. nan -nan
  4. D. inf -inf

Correct answer: D. inf -inf

Parsing a float string that is too large gives infinity rather than an error. Its negative is -infinity.

More Python Programming questions

Exams that ask this topic