Pearson Edexcel 1CP2 GCSE Computer Science · Topic 1: Computational Thinking

Stretch tasks Truth Tables and Logic

Task 1

Quiz Challenge

A quiz game against four computer players, then short and long written answers.

  1. Quiz Blitz12 questions against the clock
  2. Quick Fire4 short answers
  3. Big Think2 long answers

About 20 minutes

Task 2

This or That

Pixel the cat asks 8 questions. Each has two answers: pick the right one.

  • Two answers to every question
  • A fish treat for every right answer
  • Streaks win Pixel shades, then a party hat

About 4 minutes

Task 3

Memory Match

Flip the cards two at a time to match each term card to its meaning card.

  • 12 cards: each term has a meaning
  • One peek at every card
  • Combo points for pairs found in a row

6 pairs, about 4 minutes

Task 4

Sort It

Sort each statement into the right box, like the tick-box tables in the exam.

  • 12 cards to sort into 2 boxes
  • Drag a card, tap a box or press its number
  • Combo points for cards sorted in a row

12 cards, about 4 minutes

The games need JavaScript. Every question is below, with the answers at the end.

Read the lesson: Truth Tables and Logic

Truth Tables and Logic: the questions

Quiz Challenge, round 1: Quiz Blitz

  1. When is A AND B true?

    • Always
    • Only when both A and B are true
    • When either is true
    • When neither is true
  2. When is A OR B false?

    • Only when both A and B are false
    • When either is false
    • When both are true
    • Never
  3. How many rows does a truth table with three inputs need?

  4. What is NOT 1?

  5. In Boolean logic, 1 OR 1 = 1.

    • True
    • False
  6. A = 0, B = 0, C = 1. What is A AND (B OR C)?

  7. A = 0, B = 0, C = 1. What is (A AND B) OR C?

  8. Which expression means 'neither A nor B'?

    • NOT A AND NOT B
    • NOT A OR NOT B
    • A AND B
    • A OR B
  9. A fire door unlocks if the alarm (A) sounds, or if the release (M) is pressed and there is no lockdown (L). Which expression?

    • NOT A OR M OR L
    • A OR (M AND NOT L)
    • (A OR M) AND NOT L
    • A AND M AND NOT L
  10. In a three-input truth table, how does the last input column run?

    • 0, 1, 0, 1 ... changing every row
    • 0, 0, 0, 0, then 1, 1, 1, 1
    • 0, 0, 1, 1 ... in pairs
    • All 1s
  11. Which TWO are logical operators?

    Tick 2.

    • SET
    • AND
    • NOT
    • DIV
    • MOD
  12. Why should each bracket get its own working column?

    • It prevents errors, and each correct column can earn a mark
    • Brackets cannot be worked out otherwise
    • It makes the table shorter
    • It is needed for two-input tables only

Quiz Challenge, round 2: Quick Fire

  1. Explain why a truth table for three inputs has eight rows. [2 marks]

  2. Explain why A AND (B OR C) and (A AND B) OR C are different expressions. Use input values in your answer. [2 marks]

  3. Explain the difference between OR in Boolean logic and 'or' in everyday English. [2 marks]

  4. A program should only let in users aged 13 or over who have consent or are supervised. Explain the bug in this condition, and how to fix it. [2 marks]

    if age >= 13 and has_consent or is_supervised:
        allow_access()

Quiz Challenge, round 3: Big Think

  1. Describe a method for building a truth table for a three-input expression such as (A AND B) OR (NOT C) that avoids errors, and explain why each step helps. [6 marks]

  2. Evaluate the claim: 'Truth tables are only useful for drawing logic circuits, not for programming.' [6 marks]

This or That: tick the right answer

  1. 1 AND 0?

    • 0
    • 1
  2. 1 OR 0?

    • 0
    • 1
  3. Two inputs: how many truth table rows?

    • 2
    • 4
  4. 'Between 13 and 65': AND or OR?

    • AND
    • OR
  5. 'Under 13 or over 65': AND or OR?

    • OR
    • AND
  6. NOT (1 AND 1)?

    • 0
    • 1
  7. A = 1 and B = 0. What is A AND NOT B?

    • 0
    • 1
  8. Show the working columns, or only the final answer?

    • Only the final answer
    • The working columns

Memory Match: match each term to its meaning

TermMeaning
A AND1 Flips its input
B OR2 A component performing one logical operation
C NOT3 True only when every input is true
D Truth table4 A value that is only true or false
E Boolean5 True when at least one input is true
F Logic gate6 Every input combination with its output

Sort It: tick one box in each row

Does each expression output 1 or 0?

StatementOutput 1Output 0
0 OR 0
NOT (1 OR 0)
(1 AND 0) OR 1
1 OR 0
0 OR 1
1 AND 1
1 AND (0 OR 0)
1 AND 0
NOT 0
NOT 0 AND 1
0 AND 1
NOT 1
Answers

Round 1: Quiz Blitz

  1. Only when both A and B are true AND is true only when everything is true.
  2. Only when both A and B are false OR is false only when everything is false.
  3. 8 2 x 2 x 2 = 8 combinations.
  4. 0 NOT flips whatever it is given.
  5. True OR is true when at least one input is true, and that includes both.
  6. 0 B OR C is 1, but A is 0, so the AND gives 0.
  7. 1 A AND B is 0, then 0 OR 1 is 1. Brackets change the answer.
  8. NOT A AND NOT B Both must be false, so both NOTs must be true.
  9. A OR (M AND NOT L) With the alarm sounding the door must unlock, whatever else is true.
  10. 0, 1, 0, 1 ... changing every row Last column alternates, middle in pairs, first in fours.
  11. AND; NOT The three are AND, OR and NOT.
  12. It prevents errors, and each correct column can earn a mark Do not evaluate a combined expression in your head.

Round 2: Quick Fire

    • Each input can only be 0 or 1
    • 2 x 2 x 2 = 8 combinations, one row each
    Model answer

    Each input can only be 0 or 1, so there are two values for each. With three inputs that gives 2 x 2 x 2 = 8 combinations, and the table needs one row for every combination.

    • The brackets are evaluated first, changing the order
    • With A = 0, B = 0, C = 1, one gives 0 and the other gives 1
    Model answer

    The brackets are evaluated first, so they change the order of the operations. With A = 0, B = 0 and C = 1, A AND (B OR C) gives 0, because A is 0, but (A AND B) OR C gives 1, because C is 1.

    • Boolean OR is true when both inputs are true too
    • Everyday 'or' often means one or the other but not both
    Model answer

    In Boolean logic, OR is true when at least one input is true, including when both are true. In everyday English, 'or' often means one or the other but not both, as in tea or coffee.

    • and is evaluated before or, so is_supervised alone lets anyone in
    • Add brackets around the or
    Model answer

    and is evaluated before or, so the condition reads as (age >= 13 and has_consent) or is_supervised. A supervised child under 13 is let in, because is_supervised on its own makes the whole condition true. Adding brackets fixes it: age >= 13 and (has_consent or is_supervised).

Round 3: Big Think

    • Work out the rows: 2 x 2 x 2 = 8
    • So every combination appears exactly once
    • The last input column alternates 0, 1
    • The middle column goes in pairs and the first in fours
    • Add a working column for each bracket
    • So the brackets are evaluated first, not in your head
    • A correct working column can earn its mark even after a slip
    • Check the rows that are easy to rush, such as the last row
    Model answer

    First work out the number of rows: with three inputs there are 2 x 2 x 2 = 8 rows, so a table with any other number is already wrong. Fill the input columns in a fixed pattern: the last column alternates 0, 1, 0, 1, the middle column goes in pairs and the first column in fours. This guarantees every combination appears exactly once. Then add a working column for each bracket, A AND B and NOT C, and fill those in before the final column, so the brackets are evaluated first and nothing is done in your head. A correct working column also earns its mark even if the final column has a slip. Finally, check the rows that are easy to rush, such as the last row, where A AND B is 1 so the output is 1 even though NOT C is 0.

    • Program conditions are Boolean expressions
    • An example condition with brackets
    • A truth table shows every combination of a condition's inputs
    • So it exposes bugs such as a missing bracket
    • It gives test data for each branch
    • Truth tables are used for logic gates too
    • And for checking real systems such as a fire door
    • A conclusion that the claim is wrong
    Model answer

    The claim is wrong. Every condition in a program, such as an if statement or a while loop, is a Boolean expression, for example age >= 13 AND (has_consent OR is_supervised). A truth table lists every possible combination of the inputs, so it shows exactly when the condition is true, and it exposes bugs such as a missing bracket that lets the wrong users in. It also gives test data: one test for each row checks the code behaves as intended. Truth tables are certainly used for logic gates in circuits, but they are equally useful for checking real systems such as a fire door or a login. Overall, I disagree: they are a tool for any Boolean logic, not just hardware.

This or That

  1. 0 AND needs both inputs to be 1.
  2. 1 OR needs at least one input to be 1.
  3. 4 2 x 2 = 4 combinations.
  4. AND age >= 13 AND age <= 65: both conditions must hold.
  5. OR Nobody is both under 13 and over 65, so AND would never be true.
  6. 0 1 AND 1 is 1, and NOT flips it to 0.
  7. 1 NOT B is 1, and 1 AND 1 is 1.
  8. The working columns Marks are often given per column, so a correct working column scores even after a slip.

Memory Match

  • A 3 AND: True only when every input is true
  • B 5 OR: True when at least one input is true
  • C 1 NOT: Flips its input
  • D 6 Truth table: Every input combination with its output
  • E 4 Boolean: A value that is only true or false
  • F 2 Logic gate: A component performing one logical operation

Sort It

  1. Output 0 0 OR 0 OR is false only when everything is false.
  2. Output 0 NOT (1 OR 0) 1 OR 0 is 1, and NOT flips it to 0.
  3. Output 1 (1 AND 0) OR 1 1 AND 0 is 0, then 0 OR 1 is 1.
  4. Output 1 1 OR 0 At least one input is 1.
  5. Output 1 0 OR 1 One input is 1, so OR gives 1.
  6. Output 1 1 AND 1 Both inputs are 1, so AND gives 1.
  7. Output 0 1 AND (0 OR 0) 0 OR 0 is 0, then 1 AND 0 is 0.
  8. Output 0 1 AND 0 AND needs both inputs to be 1.
  9. Output 1 NOT 0 NOT flips 0 to 1.
  10. Output 1 NOT 0 AND 1 NOT 0 is 1, then 1 AND 1 is 1.
  11. Output 0 0 AND 1 One input is 0, so AND gives 0.
  12. Output 0 NOT 1 NOT flips 1 to 0.