- A = 1, B = 0
- A = 0, B = 1
- A = 0, B = 0
- A = 1, B = 1
Truth tables and logic
Revision notes
The logical operators AND, OR and NOT combine True/False (1/0) values. You need to complete truth tables with up to three inputs and use logic to solve problems, such as writing a logic statement for a control system. Truth table questions are usually worth 2 to 4 marks.
Key facts
- 1 = True, 0 = False
- AND: 1 only if both inputs are 1
- OR: 1 if at least one input is 1
- NOT: reverses the input (NOT 1 = 0, NOT 0 = 1)
- Rows = 2inputs: 2 inputs → 4 rows, 3 inputs → 8 rows
- Three-input columns: A 00001111, B 00110011, C 01010101
- Order: brackets, NOT, AND, OR
- Python: and, or, not
Notes
The three logical operators
diagram
- 1 means True (on, yes) and 0 means False (off, no).
- AND: the output is 1 only if both inputs are 1.
- OR: the output is 1 if at least one input is 1.
- NOT: has one input, and the output is the opposite: NOT 1 = 0 and NOT 0 = 1.
A B A AND B A OR B 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1
The three operators drawn as logic gates: AND (D shape), OR (curved) and NOT (triangle with a circle)
- Order: brackets first, then NOT, then AND, then OR.
Building a truth table
- Number of rows = 2number of inputs: 2 inputs give 4 rows and 3 inputs give 8 rows.
- List the inputs in binary counting order, 000 to 111. With three inputs, column A goes 0000 1111, B goes 0011 0011 and C goes 0101 0101.
- Add a working column for each part of the statement, then the output column. For P = (A AND B) OR NOT C:
A B C A AND B NOT C P 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 1 1 0 1 1 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 0 1 1 1 1 1 1 1 0 1 - P is 1 in every row where at least one of the two working columns is 1.
Solving problems with logic
diagram
- Give each condition a letter, then join them with AND, OR and NOT, using brackets to show which parts go together.
- Example: an alarm (S) sounds if a door is opened (D) while the system is set (T), or if the panic button (P) is pressed: S = (D AND T) OR P.
The brackets show which part is worked out first: D AND T, then OR P
- Words to look for: 'both' means AND; 'either' or 'at least one' means OR; 'not' means NOT; 'but not' means AND NOT.
- In Python the operators are
and,orandnot, used with True and False, e.g.if (door and alarmSet) or panic:. - Edexcel questions write logic statements in words, using AND, OR and NOT with brackets, e.g. P = A AND NOT B. Work through a long statement one part at a time, just like the working columns.
How to answer each type of question
Complete a truth table
- Check that the input columns are in binary counting order.
- Add a working column for the part in brackets.
- Work out the output row by row from the working column and the other input.
Example. Complete the truth table for X = A AND (B OR C).
| A | B | C | B OR C | X |
|---|---|---|---|---|
| 0 | 0 | 0 | ||
| 0 | 0 | 1 | ||
| 0 | 1 | 0 | ||
| 0 | 1 | 1 | ||
| 1 | 0 | 0 | ||
| 1 | 0 | 1 | ||
| 1 | 1 | 0 | ||
| 1 | 1 | 1 |
Show the model answerHide the model answer
| A | B | C | B OR C | X |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Complete a truth table with NOT outside brackets
- Work out the part inside the brackets first, in its own column.
- Reverse that whole column for the NOT.
- Then combine it with the remaining input.
Example. Complete the truth table for P = NOT (A AND B) AND C.
| A | B | C | A AND B | NOT (A AND B) | P |
|---|---|---|---|---|---|
| 0 | 0 | 0 | |||
| 0 | 0 | 1 | |||
| 0 | 1 | 0 | |||
| 0 | 1 | 1 | |||
| 1 | 0 | 0 | |||
| 1 | 0 | 1 | |||
| 1 | 1 | 0 | |||
| 1 | 1 | 1 |
Show the model answerHide the model answer
| A | B | C | A AND B | NOT (A AND B) | P |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 |
Write a logic statement for a situation
- Match each condition in the description to its input letter.
- Decide which conditions must all be true (AND), which are alternatives (OR) and which must be false (NOT).
- Add brackets so that the statement groups the conditions as described.
Example. A greenhouse fan (F) is controlled by three inputs:
T is 1 when the temperature is above 30 °C
W is 1 when the window is open
M is 1 when the manual switch is on.
The fan is on when the temperature is above 30 °C and the window is not open, or when the manual switch is on.
Write a logic statement for F.
Show the model answerHide the model answer
Use a truth table to solve a problem
- Complete (or read) the truth table for the statement.
- Find the rows where the output has the value you want.
- Give the inputs for those rows, and explain what they mean if asked.
Example. Use the statement F = (T AND NOT W) OR M for the greenhouse fan.
(a) State the number of rows in a truth table for F.
(b) The manual switch is off (M = 0). State the values of T and W that turn the fan on.
Show the model answerHide the model answer
Don’t lose marks
- Missing out or repeating a combination of inputs, so the table has the wrong rows.
- Applying NOT to the whole statement when it only applies to one input, or the other way round.
- Working out OR before AND when there are no brackets.
- Skipping the working columns and then making slips in the output column.
- Mixing 1/0 with True/False in the same table. Use the form the table already uses.
More tips
Memory tricks
- AND = all, OR = any, NOT = opposite.
- Input patterns halve each column: runs of four, then two, then one.
- Quick check: an AND column usually has few 1s; an OR column has few 0s.
- Don't share a NOT across brackets: NOT (A AND B) is not the same as NOT A AND NOT B. Work out the bracket, then reverse it.
Exam technique
- Add working columns even if the table in the question doesn't have them; you can write them next to it.
- Keep the input rows in the order the question gives. Don't reorder them.
- Read descriptions carefully for 'both', 'either', 'not' and 'but not' (AND NOT) before you write a statement.
What each grade needs
What you need to be able to do, from the first marks up to the top grade.
- Grade 3State the outputs of AND, OR and NOTAND needs both inputs to be 1; OR needs at least one; NOT reverses its input.
- Grade 4Complete a truth table with two inputsFour rows: 00, 01, 10, 11.
- Grade 5Complete a truth table with three inputsEight rows, listed in binary counting order from 000 to 111.
- Grade 6Use working columns for brackets and NOTWork out each part of the statement in its own column before the output.
- Grade 7Write a logic statement from a descriptionTurn a rule such as 'on if A and not B, or if C' into a statement.
- Grade 8Use a truth table to solve a problemFind the input combinations that give a required output.
Quick recall
- 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
- Complete the sentence: the output of the ______ operator is 1 only when both of its inputs are 1.
- AND
- Write the letters A, B and C in the order the student should do the steps.
- B, C, A
Sample questions
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.
| T | W | H | F |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 0 | 1 | |
| 0 | 1 | 0 | |
| 0 | 1 | 1 | |
| 1 | 0 | 0 | |
| 1 | 0 | 1 | |
| 1 | 1 | 0 | |
| 1 | 1 | 1 |
Show the answer and mark scheme
- 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
T | W | H | F --+---+---+-- 0 | 0 | 0 | 0 0 | 0 | 1 | 1 0 | 1 | 0 | 0 0 | 1 | 1 | 1 1 | 0 | 0 | 1 1 | 0 | 1 | 1 1 | 1 | 0 | 0 1 | 1 | 1 | 1
- F column, rows 1–2: 0, 1
- F column, rows 3–4: 0, 1
- F column, rows 5–6: 1, 1
- F column, rows 7–8: 0, 1
- W = 1 and H = 0
rideOpen – True when the ride is opentallEnough – True when the rider is at least 120 cm tallwithAdult – True when the rider is with an adultA rider may board only if the ride is open and the rider is either tall enough or with an adult (or both).
if statement that outputs Board when a rider may board.rideOpen and tallEnough or withAdult instead.Complete the truth table in Table 2. 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.| R | T | W | X | Y |
|---|---|---|---|---|
| 0 | 0 | 0 | ||
| 0 | 0 | 1 | ||
| 0 | 1 | 0 | ||
| 0 | 1 | 1 | ||
| 1 | 0 | 0 | ||
| 1 | 0 | 1 | ||
| 1 | 1 | 0 | ||
| 1 | 1 | 1 |
Show the answer and mark scheme
if rideOpen and (tallEnough or withAdult):
print("Board")rideOpen and…(tallEnough or withAdult)in brackets, withprint("Board")inside the if statement
R | T | W | X | Y --+---+---+---+-- 0 | 0 | 0 | 0 | 0 0 | 0 | 1 | 0 | 1 0 | 1 | 0 | 0 | 0 0 | 1 | 1 | 0 | 1 1 | 0 | 0 | 0 | 0 1 | 0 | 1 | 1 | 1 1 | 1 | 0 | 1 | 1 1 | 1 | 1 | 1 | 1
- X column, rows 1–4: 0, 0, 0, 0
- X column, rows 5–8: 0, 1, 1, 1
- Y column, rows 1–4: 0, 1, 0, 1
- Y column, rows 5–8: 0, 1, 1, 1
- 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
More in Computational thinking
Stuck? Get 1-to-1 help.
Chhetri Academy tutors GCSE and A level Maths and Science online, with a free 30-minute trial lesson.