Practise Truth tables and logic. 18 exam-style questions plus unlimited generated ones on this subtopic, at up to four difficulty levels, with full mark schemes and a progress tracker. Free, no account needed.
Cover the answers and test yourself. The app has these as flashcards that come back just before you'd forget them.
Logic statements use the operators AND, OR and NOT. Each input and each output is either 0 (False) or 1 (True). State the output of NOT when its input is 1.
0
State the Python logical operator that gives True only when both of the conditions it joins are True.
and
A car has a warning light, W. The light comes on when the fuel is low (F = 1) or when the tyre pressure is low (T = 1). Write a logic statement for W.
W = F OR T
Sample questions
Written for this site in the style of Edexcel exam questions. They are not taken from real past papers.
Question 1Easy5 marks
Logic statements use the operators AND, OR and NOT. Each input and each output is either 0 (False) or 1 (True).
(a) Complete the truth table in {table}.[2]
[object Object]
(b) State the output of NOT when its input is 1.[1]
(c) A lamp, L, is controlled by two switches, S and T. The lamp is on only when both switches are on. Identify the logic statement that describes the lamp.[1]
L = S OR T
L = S AND T
L = NOT S
L = NOT (S AND T)
(d) State the number of different combinations of inputs for a logic statement that has three inputs.[1]
Show the answer and mark scheme
(a)Answer:
A | B | A AND B | A OR B
--+---+---------+-------
0 | 0 | 0 | 0
0 | 1 | 0 | 1
1 | 0 | 0 | 1
1 | 1 | 1 | 1
A AND B column: 0, 0, 0, 1
A OR B column: 0, 1, 1, 1
(b)Answer: 0
0 / False
(c)Answer: L = S AND T
(d)Answer: 8 (2 × 2 × 2)
8
Question 2Medium7 marks
A greenhouse has a fan, F, that is controlled by three inputs: T = 1 when the temperature is above 30 °C W = 1 when a window is open H = 1 when the humidity is high The fan switches on (F = 1) when the temperature is above 30 °C and the window is not open, or when the humidity is high.
(a) Write a logic statement for F.[2]
(b) Complete the truth table in {table} for F.[4]
[object Object]
(c) The temperature is above 30 °C but the fan is off. State the values of W and H.[1]
Show the answer and mark scheme
(a)Answer: F = (T AND NOT W) OR H
T AND NOT W
combined with H using OR so that H = 1 on its own switches the fan on: F = (T AND NOT W) OR H
(c)Answer: W = 1 and H = 0 (the window is open and the humidity is not high)
W = 1 and H = 0
Question 3Hard8 marks
A theme park ride uses three Boolean variables: rideOpen – True when the ride is open tallEnough – True when the rider is at least 120 cm tall withAdult – True when the rider is with an adult A rider may board only if the ride is open and the rider is either tall enough or with an adult (or both).
(a) Write a Python if statement that outputs Board when a rider may board.[2]
(b) A programmer writes the condition as rideOpen and tallEnough or withAdult instead. Complete the truth table in {table}. R, T and W stand for rideOpen, tallEnough and withAdult. Column X is the correct condition, R AND (T OR W). Column Y is the programmer's condition.[4]
[object Object]
(c) Use your truth table to explain the problem with the programmer's condition.[2]
Show the answer and mark scheme
(a)Answer:
if rideOpen and (tallEnough or withAdult):
print("Board")
rideOpen and …
(tallEnough or withAdult) in brackets, with print("Board") inside the if statement
(c)Answer: X and Y differ when the ride is closed and the rider is with an adult (rows 2 and 4). Because and is evaluated before or, withAdult being True makes the programmer's condition True on its own, so a rider with an adult could board a closed ride.
the two columns differ when R = 0 and W = 1 / when the ride is closed and the rider is with an adult
because and is evaluated before or, withAdult on its own makes the condition True / a rider with an adult could board when the ride is closed