ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(bool(0.0), bool(-0.0), bool(1e-300), bool(float('nan')))
  1. A. False True True True
  2. B. True False True True
  3. C. False False True True
  4. D. False False True False

Correct answer: C. False False True True

Zero floats, including -0.0, are false. Any other nonzero float is true, and NaN is true because it is not zero.

More Python Programming questions

Exams that ask this topic