Mathematics I / Conditionals and Boolean Logic
Practice question · True or false

Short-circuit evaluation of a AND b is what makes if x != 0 and 10/x > 1 safe.

Hints
  1. What happens to the division when x is zero?
  2. A false left side settles the expression.
Show the answer

True

Why

True. A false left operand fixes the whole conjunction as false, so the right side is never evaluated and the division never happens. It also means AND is not commutative once either side can fault, swapping the operands here crashes on exactly the input the guard was written for.

Read the lesson: Conditionals and Boolean Logic →

Practise Conditionals and Boolean Logic

The app has 7 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Conditionals and Boolean Logic