ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print(3 in {1, 2, 3} and 'x' in 'xyz', [] or () or None)
  1. A. True [0]
  2. B. False None
  3. C. True None
  4. D. True ()

Correct answer: C. True None

The membership tests are both True, so the and expression is True. Every operand in the or chain is falsy, so or returns the last one, None.

More Python Programming questions

Exams that ask this topic