All subjects · Computer Science · WCP01 Principles of Computer Science
Boolean expressions and truth tables
Edexcel IAL Computer Science · WCP01 Principles of Computer Science
Boolean logic combines true (1) and false (0) values with operators. You must interpret and create Boolean expressions and complete truth tables (spec points 5.3.1 and 5.3.2).
The operators
| A | B | A AND B | A OR B | A XOR B | A NAND B | A NOR B |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
NOT A simply inverts: NOT 0 = 1, NOT 1 = 0.
Notation and precedence
In Boolean algebra notation (as used in Pearson mark schemes): A.B means A AND B, A + B means A OR B, a bar over A means NOT A, and A ⊕ B means A XOR B. NAND is NOT (A AND B); NOR is NOT (A OR B).
Order of precedence: brackets first, then NOT, then AND, then OR. So NOT A AND B OR C means ((NOT A) AND B) OR C. Use brackets whenever you mix XOR, NAND or NOR with other operators, so there is no ambiguity.
Building truth tables
- With n inputs there are 2n rows; list inputs counting up in binary (00, 01, 10, 11).
- Add a column for each part of the expression, working from the inside out, then the final output.
- To create an expression from a description, pick out the conditions and joining words: 'the alarm (Q) sounds if the door is open (A) and the system is armed (B), or the panic button is pressed (C)' gives Q = (A AND B) OR C.
- To create an expression from a truth table, find each row where Q = 1, write it as an AND of inputs (NOT for 0s), then OR those terms together.
| A | B | C | NOT B | A AND NOT B | Q = (A AND NOT B) OR C |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 1 |
Worked example
A pump (Q) should run when the tank is not full (A is the 'full' sensor) and either the timer (B) or the manual switch (C) is on. Write the expression and find Q when A = 0, B = 0, C = 1.
- 'Not full' is NOT A.
- 'Either B or C' is (B OR C); the brackets matter.
- Q = NOT A AND (B OR C)
- A = 0, B = 0, C = 1: NOT A = 1, B OR C = 1, Q = 1 AND 1
- In Boolean algebra notation: Q = Ā.(B + C)
Answer: Q = NOT A AND (B OR C), written Ā.(B + C); Q = 1
Check yourself
- How many rows (excluding the heading) does a truth table with 4 inputs need?
Show answer
16. 24 = 16.
- What is the output of A NAND B when A = 1 and B = 1?
Show answer
0. 1 AND 1 = 1; NOT 1 = 0.
- Evaluate NOT A AND B OR C when A = 1, B = 1 and C = 0.
Show answer
0. Precedence: (NOT A) = 0; 0 AND 1 = 0; 0 OR 0 = 0.
- In the truth table for Q = (A AND NOT B) OR C with three inputs, how many rows have Q = 1?
Show answer
5. Q = 1 when C = 1 (4 rows) or when A = 1, B = 0, C = 0 (1 row): 5.
- Give the output column of A XOR B for the inputs (A, B) = 00, 01, 10, 11, as four digits.
Show answer
0110. XOR is 1 when the inputs differ: 0110.
- A light (Q) comes on when the switch (S) is on and it is dark (D), or when motion (M) is detected. Which expression is correct?
- Q = S AND (D OR M)
- Q = S OR D AND M
- Q = NOT (S AND D) OR M
- Q = (S AND D) OR M
Show answer
Q = (S AND D) OR M. The two conditions S and D go together, then OR M.
- Which Boolean algebra expression means (A AND NOT B) OR C?
- A + B̄.C
- A.B̄ + C
- (A + B).C̄
- Ā.B + C
Show answer
A.B̄ + C. The dot is AND, + is OR and the bar is NOT, so (A AND NOT B) OR C is A.B̄ + C.
- Evaluate Q = A.B̄ + C̄.D when A = 1, B = 0, C = 1 and D = 0. (The bar means NOT, the dot AND and + OR.)
Show answer
1. A.B̄ = 1.1 = 1; C̄.D = 0.0 = 0; Q = 1 + 0 = 1.
Sources
- Pearson Edexcel International Advanced Subsidiary/Advanced Level in Computer Science specification (2026)
- Pearson Edexcel IAL Computer Science IAS sample assessment materials (Unit 1, WCP01)
Last updated 8 November 2026. Spotted a mistake? Tell us.