Thursday, October 15, 2026

Python Quiz: `and` vs `or` — Operand Return Behavior

 ### Python Quiz: `and` vs `or` — Operand Return Behavior

Test your Python knowledge with these 10 quiz questions, covering truthy/falsy values, short-circuit evaluation, and code output.

Key rule to remember:

* `x and y` → returns `x` if `x` is falsy; otherwise returns `y`.

* `x or y` → returns `x` if `x` is truthy; otherwise returns `y`.

Python and/or Operator Quiz


1. What is the output? print(0 or 15)

   A. 0

   B. False

   C. True

   D. 15


2. What is the output? print("Python" and "Quiz")

   A. Python

   B. False

   C. Quiz

   D. True


3. What is the output? print([] or "Empty")

   A. Empty

   B. True

   C. []

   D. False


4. What is the output? print(5 and 0 and 8)

   A. True

   B. 0

   C. 5

   D. 8


5. What is the output? print(None or False or "Done")

   A. True

   B. None

   C. False

   D. Done


6. Select every expression that evaluates to the integer 0. # Evaluate each expression independently

   A. 9 or 0

   B. 9 and 0

   C. 0 and 7

   D. 0 or 7


7. In Python, the expression "Hi" or "Bye" evaluates to the string "Hi".

   True

   False


8. In Python, [] and 10 evaluates to the integer 10 because and always returns its last operand.

   True

   False


9. What is printed? def check(): print("called") return 99 print(1 or check())

   A. called, then 1

   B. called, then 99

   C. 99 only

   D. 1 only


10. What is the output? value = "" result = value and 100 print(repr(result))

   A. None

   B. ''

   C. 100

   D. False

Quick revision tip: `and` stops at the first falsy operand; `or` stops at the first truthy operand. Both return the actual operand, 

not necessarily `True` or `False`.