ProgrammingVery hardTCS NQT · Accenture

What is printed?

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

Correct answer: D. False True True False

Each operand in the first expression is falsy, so bool gives False. [[]] is a non-empty list, [0] is non-empty, and ' '.strip() is the empty string, which is False.

More Python Programming questions

Exams that ask this topic