Logical Operators
A truth table lists every possible combination of input truth values for a logical expression and the output produced for each combination. It lets you check what an expression does in every case, rather than just one example.
An expression with one input condition has two possible input combinations: True and False. With two input conditions there are four combinations. Write them systematically, such as True/True, True/False, False/True, False/False. The rows can be in any order, but each combination must appear once and no input combination should be left out, even when its output is False.
Complete a truth table by applying the logical operator to each row of inputs.
| A | B | A AND B | A OR B |
|---|---|---|---|
| True | True | True | True |
| True | False | False | True |
| False | True | False | True |
| False | False | False | False |
If A stands for has_key and B stands for score_at_least_100, the AND column shows that the level unlocks only in the first row, where both are True. The OR column is True in the first three rows because at least one input is True.
| A | NOT A |
|---|---|
| True | False |
| False | True |
NOT reverses its single input, so NOT has_key is True exactly when has_key is False.
You can write truth values as True and False, or as 1 and 0. Choose one style and use it for the whole table; do not mix them, and avoid ticks or crosses.
Edexcel GCSE Computer Science · Logical Operators