Edexcel GCSE CS · 1.3
Truth Tables and Logic
Name
Class
Date
Mark / 28
Section A
Circle the letter of the correct answer. One mark each.
- 1What is the output of 1 AND 0?1
- AIt depends on the other inputs
- B0
- C1
- DBoth 0 and 1
- 2How many rows does a truth table with three inputs have?1
- A3
- B6
- C8
- D9
- 3What is the output of NOT (1 OR 0)?1
- AIt depends on NOT being applied first
- B1
- CUndefined
- D0
- 4Which expression is true only when both A and B are false?1
- ANOT A AND NOT B
- BNOT A OR NOT B
- CNOT (A AND B)
- DA AND B
- 5For A equals 0, B equals 0 and C equals 1, what is the value of (A AND B) OR C?1
- AIt cannot be evaluated
- B1
- C2
- D0
- 6Which statement about the OR operation is correct?1
- AIt outputs 1 only when exactly one input is 1
- BIt outputs 1 when one or both inputs are 1
- CIt outputs 0 when either input is 1
- DIt outputs 1 only when both inputs are 1
- 7A door opens if a valid card is presented AND the door is not locked down. Which expression is correct?1
- ANOT (card AND lockdown)
- Bcard OR NOT lockdown
- Ccard AND lockdown
- Dcard AND NOT lockdown
- 8Why is a working column added when building a truth table for (A OR B) AND NOT C?1
- AIt is required by the specification for every table
- BIt converts the expression to binary
- CIt records the value of each sub expression so the final column is less error prone
- DIt reduces the number of rows needed
- 9In Python, why does the condition age > 12 and consent or supervised behave differently from age > 12 and (consent or supervised)?1
- ABecause and is evaluated before or, so the first reads as (age > 12 and consent) or supervised
- BBecause Python evaluates conditions from right to left
- CBecause and can only be used once in a condition
- DBecause or is not a valid operator without brackets
- 10Which set of inputs makes A AND (B OR C) different in value from (A AND B) OR C?1
- AA equals 1, B equals 0, C equals 0
- BA equals 1, B equals 1, C equals 1
- CA equals 0, B equals 0, C equals 1
- DA equals 0, B equals 0, C equals 0
Section B
Answer in the space provided. The number of marks tells you how many separate points to make.
- 1CalculateComplete a truth table for the expression A AND NOT B, and state for which inputs the output is 1.2
- 2ExplainExplain the difference between the AND and the OR logical operations.3
- 3WriteA greenhouse system opens a vent if the temperature is above 28 degrees, or if the humidity is above 80 per cent and the fan is not running. Write a Boolean expression for this system, defining each variable you use.4
- 4CalculateComplete the truth table for the expression (A OR B) AND NOT C and describe the pattern in the output.4
- 5ExplainA student writes the condition if age > 65 or age < 16 and has_pass: in a program that should give a discount to anyone over 65, and to anyone under 16 who holds a pass. Explain why this condition does not do what the student intended, and how to correct it.5
Mark scheme
Section A
Section B
1 Complete a truth table for the expression A AND NOT B, and state for which inputs the output is 1. 2
One mark for each of the following, to a maximum of 2.
- Shows all four combinations of A and B
- Identifies that the output is 1 only when A is 1 and B is 0
Model answer. The table has four rows because there are two inputs. When A is 0 and B is 0 the output is 0, when A is 0 and B is 1 the output is 0, when A is 1 and B is 0 the output is 1, and when A is 1 and B is 1 the output is 0. The output is therefore 1 for exactly one combination, where A is 1 and B is 0, because AND requires both of its inputs to be true and NOT B is only true when B is false.
2 Explain the difference between the AND and the OR logical operations. 3
One mark for each of the following, to a maximum of 3.
- AND outputs true only when all of its inputs are true
- OR outputs true when at least one of its inputs is true
- OR is therefore true in more cases, and is only false when every input is false
Model answer. AND produces an output of true only when every one of its inputs is true, so with two inputs it is true in just one of the four possible combinations. OR produces an output of true whenever at least one of its inputs is true, including the case where both are true, so with two inputs it is true in three of the four combinations. Put the other way round, AND is false as soon as any input is false, while OR is false only when every input is false.
3 A greenhouse system opens a vent if the temperature is above 28 degrees, or if the humidity is above 80 per cent and the fan is not running. Write a Boolean expression for this system, defining each variable you use. 4
One mark for each of the following, to a maximum of 4.
- Defines a variable for each condition, such as T for high temperature, H for high humidity and F for the fan running
- Uses AND to combine the humidity condition with the fan condition
- Applies NOT to the fan variable only
- Uses OR to combine the temperature condition with the humidity and fan condition, with correct bracketing
Model answer. Let T represent the temperature being above 28 degrees, H represent the humidity being above 80 per cent, and F represent the fan running. The vent opens when T is true on its own, or when H is true at the same time as F is false. The expression is therefore vent equals T OR (H AND NOT F). The brackets are essential, because they keep the humidity and fan conditions together as a single requirement: without them the expression would open the vent whenever the humidity was high, regardless of the fan.
4 Complete the truth table for the expression (A OR B) AND NOT C and describe the pattern in the output. 4
One mark for each of the following, to a maximum of 4.
- Recognises that three inputs give eight rows
- Evaluates A OR B correctly as true whenever A or B is 1
- Evaluates NOT C correctly as the inverse of C
- States that the output is 1 only when C is 0 and at least one of A and B is 1
Model answer. There are three inputs so the table has eight rows. The column for A OR B is 0 only in the two rows where both A and B are 0, and 1 in the other six. The column for NOT C is 1 in the four rows where C is 0 and 0 in the four where C is 1. The final column is the AND of those two working columns, so it is 1 only where both are 1. That gives an output of 1 in exactly three rows: A equals 0 with B equals 1 and C equals 0, A equals 1 with B equals 0 and C equals 0, and A equals 1 with B equals 1 and C equals 0. In words, the output is true only when C is false and at least one of A and B is true.
5 A student writes the condition if age > 65 or age < 16 and has_pass: in a program that should give a discount to anyone over 65, and to anyone under 16 who holds a pass. Explain why this condition does not do what the student intended, and how to correct it. 5
One mark for each of the following, to a maximum of 5.
- Identifies that AND is evaluated before OR
- So the condition is treated as age > 65 OR (age < 16 AND has_pass)
- States that this actually matches the intention for the under 16 case
- Notes the risk that a reader cannot see the grouping, so the code is easy to misread and to break when edited
- Corrects it by adding brackets, for example if age > 65 or (age < 16 and has_pass)
Model answer. In Python the AND operator has higher precedence than OR, so the condition is evaluated as age greater than 65, OR the pair age less than 16 AND has_pass taken together. In this particular case that grouping happens to match what the student wanted, since a person under 16 does need a pass while a person over 65 does not. The problem is that nothing in the code says so. Anyone reading the line has to know the precedence rules to work out the grouping, and a small future edit, such as adding a third condition, can silently change the meaning and introduce a fault that produces no error message. The correction is to make the grouping explicit by writing if age > 65 or (age < 16 and has_pass), which behaves identically but states the intention on the page rather than leaving it to be inferred.