To evaluate a Boolean expression, replace each letter with its value (1 for true, 0 for false) and work out the operators in a fixed order: brackets first, then NOT, then AND, then OR. Every step produces another 1 or 0, so a long expression is just a short chain of small decisions.
This skill sits at the start of the Boolean logic module. It supports truth tables, circuits and the conditions you write in your own algorithms.
What do the three operators do?
- NOT flips a value: NOT 1 = 0 and NOT 0 = 1.
- AND gives 1 only when both inputs are 1.
- OR gives 1 when at least one input is 1.
In Cambridge-style pseudocode these are written as the words NOT, AND and OR. The same idea inside a condition looks like this:
IF (Age >= 13) AND NOT (HasConsent) THEN
OUTPUT "Ask a parent first"
ENDIF
How to evaluate step by step
- Substitute the value for every letter and write it under the letter.
- Work out every bracket, innermost first.
- Apply NOT to the single value or bracket directly after it.
- Apply AND from left to right.
- Apply OR last. The final 1 or 0 is the answer.
Worked example
Find Q = (A OR B) AND NOT C when A = 0, B = 1 and C = 0.
Step 1, substitute: (0 OR 1) AND NOT 0.
Step 2, bracket: 0 OR 1 = 1, so the expression is 1 AND NOT 0.
Step 3, NOT: NOT 0 = 1, so the expression is 1 AND 1.
Step 4, AND: 1 AND 1 = 1.
Q = 1. Now change C to 1 and repeat: (0 OR 1) AND NOT 1 = 1 AND 0 = 0. One input changes, the output changes, and the same steps apply.
The mistake to watch for
Students sometimes ignore the operator order and read from left to right. Take A = 1, B = 0, C = 0 and the expression A OR B AND C with no brackets.
Mistaken working: (1 OR 0) AND 0 = 1 AND 0 = 0.
AND comes before OR, so the correct working is 1 OR (0 AND 0) = 1 OR 0 = 1. If the question really had brackets, (A OR B) AND C, then the answer would be 0. The brackets decide the answer, so copy them exactly and never move them.
You can test your reasoning in Python, where a or b and c follows the same order. The restricted pseudocode trace trainer and the safe Python reasoning sandbox are useful for checking small cases.
Check yourself
1. Find NOT (X AND Y) when X = 1 and Y = 1.
Show answer
Bracket first: 1 AND 1 = 1. Then NOT 1 = 0.
2. Find (P OR Q) AND NOT R when P = 0, Q = 1 and R = 1.
Show answer
(0 OR 1) = 1. NOT 1 = 0. Then 1 AND 0 = 0.
3. Find NOT A OR B AND C when A = 0, B = 1 and C = 0 (no brackets).
Show answer
NOT first: NOT 0 = 1. AND next: 1 AND 0 = 0. OR last: 1 OR 0 = 1.
Where this leads next
Once evaluation is automatic, move on to constructing a truth table, where you evaluate the same expression for every possible input. Then try the Boolean logic practice set. The Boolean and number-representation lab lets you test small expressions of your own.
If a Boolean answer still goes wrong although each rule makes sense, a teacher can trace the slip with you. That is the focus of our online one-to-one Computer Science tuition.