ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print([] == [] or 1 / 0, [] and 1 / 0, 0 or 1 and 2)
  1. A. False [] 2
  2. B. True [] 1
  3. C. True [] 2
  4. D. True ZeroDivisionError 2

Correct answer: C. True [] 2

[] == [] is True, so or stops there and never divides by zero. [] is falsy, so and returns it without evaluating the division. 0 or (1 and 2) gives 2.

More Python Programming questions

Exams that ask this topic