ProgrammingHardAccenture · Cognizant · Python

What does the following Python 3 code print? print(bool([]), bool({}), bool(()), bool(0.0), bool("0"))

  1. A. True True True False True
  2. B. False False False False True
  3. C. False False False False False
  4. D. False False False True True

Correct answer: B. False False False False True

Empty containers and 0.0 are falsy, but the non-empty string "0" is truthy regardless of its text content.

More Python Programming questions

Exams that ask this topic