ProgrammingHardAccenture pattern

What is printed?

What is printed?
x = None
print(x or "default")
y = 0
print(y or "default")
z = ""
print(z or "fallback")
  1. A. None 0 True
  2. B. default default fallback
  3. C. default 0 fallback
  4. D. None default fallback

Correct answer: B. default default fallback

or returns its first truthy operand, or the last one if both are falsy. None, 0, and '' are all falsy, so each expression falls through to the fallback string on the right.

More Python Programming questions

Exams that ask this topic