Questenaتمرینی که نشان می‌دهد بعد چه چیزی را مرور کنید
سؤال 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`.پاسخ درست
  3. It evaluates both operands and always returns `True`.
  4. It raises TypeError when `x` is not already Boolean.

توضیح

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.

ادامهٔ این آزمون

شروع تمرین
سؤال 55: How does `x or y` behave when `x` is truthy? · Python Fundamentals · Questena