3.5 Boolean expressionsTrue, false, AND, OR, NOT

A Boolean value is either true or false. Relational operators compare two values and produce a Boolean: =, ≠, >, <, ≥ and ≤. Note that the exam uses a single = to test whether two values are equal, and the arrow ← for assignment, so they never get confused.
| Operator | Read it as | With x ← 7 | Value |
|---|---|---|---|
| a = b | equals | x = 7 | true |
| a ≠ b | is not equal to | x ≠ 7 | false |
| a > b | greater than | x > 7 | false |
| a < b | less than | x < 10 | true |
| a ≥ b | at least | x ≥ 7 | true |
| a ≤ b | at most | x ≤ 6 | false |
Logical operators combine Booleans. NOT flips a Boolean: NOT true is false. AND is true only when both sides are true. OR is true when at least one side is true, including when both are. A truth table lists every combination.
| A | B | A AND B | A OR B | NOT A |
|---|---|---|---|---|
| true | true | true | true | false |
| true | false | false | true | false |
| false | true | false | true | true |
| false | false | false | false | true |
?Wait, is OR "one or the other but not both"?
Ranges, and how to flip a condition
The most common Boolean on the exam describes a range. "t is from 60 to 80, inclusive" means t is at least 60 AND t is at most 80: (t ≥ 60) AND (t ≤ 80). The outside of that range is "t is below 60 OR above 80": (t < 60) OR (t > 80). A single number can't be below 60 and above 80 at once, so the outside must use OR.
To negate a combined condition, flip each comparison and swap AND with OR. NOT ((x > 10) AND (y = 2)) is the same as (x ≤ 10) OR (y ≠ 2). Notice the opposite of > is ≤, not <: if x isn't greater than 10, it could be equal to 10.
?Wait, what's the opposite of each comparison?
I thought about it. Show me
- (a) age ≥ 16 is 16 ≥ 16: true. permit is true. true AND true is true.
Why?
≥ includes equality, so 16 ≥ 16 is true. - (b) Inside the parentheses: age < 18 is true, so the OR is true (one true side is enough). NOT true is false.
Why?
Evaluate the inside first, then apply NOT. - (c) age > 16 is 16 > 16: false. NOT permit is NOT true: false. false OR false is false.
Answer: (a) true (b) false (c) false
Stuck? Get a hint
- Replace each comparison with true or false first.
- Then combine with AND or OR, using the truth table.
- NOT goes last, on the value inside its parentheses.
- A(score > 70) OR (late = true)
- B(score ≤ 70) OR (late = true)
- C(score ≤ 70) AND (late = true)
- D(score < 70) OR (late = false)
Show the answer
B. Flip each comparison (> becomes ≤, late = false becomes late = true) and swap AND with OR. Choice D uses < instead of ≤, which would leave out a score of exactly 70.
- A(temp < 32) AND (temp > 50)
- B(temp ≤ 32) OR (temp ≥ 50)
- C(temp < 32) OR (temp > 50)
- DNOT (temp > 32)
Show the answer
C. Outside means below 32 or above 50: (temp < 32) OR (temp > 50). With AND nothing is ever true, and ≤ and ≥ would wrongly include 32 and 50, which are inside the range.

When a question says "inclusive", the endpoints count: use ≥ and ≤. Then test your expression on three numbers: one inside, one outside, and one endpoint. It takes ten seconds and catches most mistakes.
- A Boolean is true or false. Relational operators: =, ≠, >, <, ≥, ≤.
- AND: both true. OR: at least one true. NOT: flips.
- Inside a range: AND. Outside a range: OR.
- To negate: flip each comparison (> ↔ ≤, < ↔ ≥, = ↔ ≠) and swap AND with OR.