QuestenaPractice that shows what to review next
Question 55

How does `x or y` behave when `x` is truthy?

  1. It evaluates `y` first and returns `y`.
  2. It returns the truthy `x` without evaluating `y`.Correct answer
  3. It evaluates both operands and always returns `True`.
  4. It raises TypeError when `x` is not already Boolean.

Explanation

The truthy first operand already determines that the expression succeeds, so Python returns `x` and skips evaluation of `y`. Always evaluating both sides would violate short-circuit behavior, and forcing a Boolean result would discard the selected operand.

Continue with this test

Start practice
Question 55: How does `x or y` behave when `x` is truthy? · Python Fundamentals · Questena