ProgrammingHardTCS NQT · Wipro pattern

What is printed?

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

Correct answer: C. True False False True True

Any non-empty string is True, including '0' and a single space. Zero floats, including -0.0, are False, but NaN is non-zero and therefore True.

More Python Programming questions

Exams that ask this topic