ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
import math
print(math.isnan(float('nan') * 0), math.isinf(1e308 * 10), math.isfinite(-0.0), math.copysign(1, -0.0))
  1. A. True True False -1.0
  2. B. True False True -1.0
  3. C. True True True -1.0
  4. D. False True True -1.0

Correct answer: C. True True True -1.0

NaN times zero is still NaN, and 1e308 * 10 overflows to infinity. Negative zero is finite and copysign reads its sign bit, so the result is -1.0.

More Python Programming questions

Exams that ask this topic