ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: C. False False True True True False

Only zero of any numeric type is falsy, and -0.0 is also zero. NaN is truthy because it is not equal to 0. A string is falsy only when it is empty, so ' ' and '0' are both truthy.

More Python Programming questions

Exams that ask this topic