ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: C. False True False True x

Only empty or zero-valued objects are false. [0] is a nonempty list, so it is true, and the non-empty string 'False' is also true. None is false, so the or returns 'x'.

More Python Programming questions

Exams that ask this topic