ProgrammingEasyAccenture · Capgemini pattern

What is printed?

What is printed?
print(bool([]), bool([0]), bool(""), bool(" "), None == False, 0 == False)
  1. A. False False False True False True
  2. B. False True False False True True
  3. C. False True False True True True
  4. D. False True False True False True

Correct answer: D. False True False True False True

Empty containers and strings are falsy; a list holding 0 and a string holding a space are non-empty, hence truthy. None is falsy but not equal to False, while 0 == False is True because bool is a subclass of int.

More Python Programming questions

Exams that ask this topic