Pearson Edexcel 1CP2 GCSE Computer Science · Topic 1: Computational Thinking
Stretch tasks Truth Tables and Logic
Quiz Challenge
A quiz game against four computer players, then short and long written answers.
- Quiz Blitz12 questions against the clock
- Quick Fire4 short answers
- Big Think2 long answers
About 20 minutes
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
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
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
When is A AND B true?
- Always
- Only when both A and B are true
- When either is true
- When neither is true
When is A OR B false?
- Only when both A and B are false
- When either is false
- When both are true
- Never
How many rows does a truth table with three inputs need?
What is NOT 1?
In Boolean logic, 1 OR 1 = 1.
- True
- False
A = 0, B = 0, C = 1. What is A AND (B OR C)?
A = 0, B = 0, C = 1. What is (A AND B) OR C?
Which expression means 'neither A nor B'?
- NOT A AND NOT B
- NOT A OR NOT B
- A AND B
- A OR B
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
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
Which TWO are logical operators?
Tick 2.
- SET
- AND
- NOT
- DIV
- MOD
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
Explain why a truth table for three inputs has eight rows. [2 marks]
Explain why A AND (B OR C) and (A AND B) OR C are different expressions. Use input values in your answer. [2 marks]
Explain the difference between OR in Boolean logic and 'or' in everyday English. [2 marks]
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
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]
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 AND 0?
- 0
- 1
1 OR 0?
- 0
- 1
Two inputs: how many truth table rows?
- 2
- 4
'Between 13 and 65': AND or OR?
- AND
- OR
'Under 13 or over 65': AND or OR?
- OR
- AND
NOT (1 AND 1)?
- 0
- 1
A = 1 and B = 0. What is A AND NOT B?
- 0
- 1
Show the working columns, or only the final answer?
- Only the final answer
- The working columns
Memory Match: match each term to its meaning
| Term | Meaning |
|---|---|
| A AND | 1 Flips its input |
| B OR | 2 A component performing one logical operation |
| C NOT | 3 True only when every input is true |
| D Truth table | 4 A value that is only true or false |
| E Boolean | 5 True when at least one input is true |
| F Logic gate | 6 Every input combination with its output |
Sort It: tick one box in each row
Does each expression output 1 or 0?
| Statement | Output 1 | Output 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
- Only when both A and B are true AND is true only when everything is true.
- Only when both A and B are false OR is false only when everything is false.
- 8 2 x 2 x 2 = 8 combinations.
- 0 NOT flips whatever it is given.
- True OR is true when at least one input is true, and that includes both.
- 0 B OR C is 1, but A is 0, so the AND gives 0.
- 1 A AND B is 0, then 0 OR 1 is 1. Brackets change the answer.
- NOT A AND NOT B Both must be false, so both NOTs must be true.
- A OR (M AND NOT L) With the alarm sounding the door must unlock, whatever else is true.
- 0, 1, 0, 1 ... changing every row Last column alternates, middle in pairs, first in fours.
- AND; NOT The three are AND, OR and NOT.
- 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 answerEach 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 answerThe 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 answerIn 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 answerand 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 answerFirst 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 answerThe 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
- 0 AND needs both inputs to be 1.
- 1 OR needs at least one input to be 1.
- 4 2 x 2 = 4 combinations.
- AND age >= 13 AND age <= 65: both conditions must hold.
- OR Nobody is both under 13 and over 65, so AND would never be true.
- 0 1 AND 1 is 1, and NOT flips it to 0.
- 1 NOT B is 1, and 1 AND 1 is 1.
- 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
- Output 0 0 OR 0 OR is false only when everything is false.
- Output 0 NOT (1 OR 0) 1 OR 0 is 1, and NOT flips it to 0.
- Output 1 (1 AND 0) OR 1 1 AND 0 is 0, then 0 OR 1 is 1.
- Output 1 1 OR 0 At least one input is 1.
- Output 1 0 OR 1 One input is 1, so OR gives 1.
- Output 1 1 AND 1 Both inputs are 1, so AND gives 1.
- Output 0 1 AND (0 OR 0) 0 OR 0 is 0, then 1 AND 0 is 0.
- Output 0 1 AND 0 AND needs both inputs to be 1.
- Output 1 NOT 0 NOT flips 0 to 1.
- Output 1 NOT 0 AND 1 NOT 0 is 1, then 1 AND 1 is 1.
- Output 0 0 AND 1 One input is 0, so AND gives 0.
- Output 0 NOT 1 NOT flips 1 to 0.