Practice question · True or false
With short-circuit evaluation, in the expression A or B, if A is true then B is still always evaluated.
Hints
- Ask whether the result is already decided once A is known to be true.
- A true left side of 'or' fixes the whole expression as true.
Show the answer
False
Why
False. If A is true, A or B is already true, so B is skipped, the mirror image of 'and' short-circuiting on a false left side. This is exactly why a guard like 'x is not zero or safe_to_divide(x)' can protect the right-hand call.
Practise Conditionals and Logical Branching
The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Conditionals and Logical Branching
- A grading program runs: if score >= 90 give A; elif score >= 80 give B; elif score >= 70 give C; else give F.…
- Sort each operator by its role.
- Python makes if x = 5 a syntax error while C compiles it happily. What is C's version actually doing?
- if x = 5 is a common bug in languages where it is legal, while if x == 5 is what was meant. Why is the…