ProgrammingVery hardJEE Main · CAT placement

What is printed?

What is printed?
print(float('1e400'), -float('1e400'), float('1e308') * 10)
  1. A. 1e400 -1e400 inf
  2. B. inf -inf 1e309
  3. C. inf -inf inf
  4. D. Infinity -Infinity inf

Correct answer: C. inf -inf inf

Parsing a number too large for a float gives inf rather than an error, and so does float multiplication that overflows. Python prints the float infinity as inf, with a minus sign for the negative one.

More Python Programming questions

Exams that ask this topic