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).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

The operators

ABA AND BA OR BA XOR BA NAND BA NOR B
0000011
0101110
1001110
1111000

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

ABCNOT BA AND NOT BQ = (A AND NOT B) OR C
000100
001101
010000
011001
100111
101111
110000
111001

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.

  1. 'Not full' is NOT A.
  2. 'Either B or C' is (B OR C); the brackets matter.
  3. Q = NOT A AND (B OR C)
  4. A = 0, B = 0, C = 1: NOT A = 1, B OR C = 1, Q = 1 AND 1
  5. In Boolean algebra notation: Q = Ā.(B + C)

Answer: Q = NOT A AND (B OR C), written Ā.(B + C); Q = 1

Key idea: AND both 1; OR at least one 1; XOR exactly one 1; NAND and NOR invert AND and OR. Precedence: brackets, NOT, AND, OR. n inputs give 2n rows.

Check yourself

  1. How many rows (excluding the heading) does a truth table with 4 inputs need?
    Show answer

    16. 24 = 16.

  2. What is the output of A NAND B when A = 1 and B = 1?
    Show answer

    0. 1 AND 1 = 1; NOT 1 = 0.

  3. 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.

  4. 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.

  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.

  6. 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.

  7. 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.

  8. 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.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.