ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
import math
x = float("inf")
print(x - x, x * 0 == x * 0, math.isnan(x / x), -x < 0 < x, 1e308 * 10 == x)
  1. A. 0 True False True True
  2. B. nan True True True False
  3. C. nan False True True OverflowError
  4. D. nan False True True True

Correct answer: D. nan False True True True

inf - inf and inf * 0 are NaN (and NaN never equals itself), inf / inf is NaN, and float multiplication that overflows gives inf rather than raising.

More Python Programming questions

Exams that ask this topic