Spec & Goals 3 min
AQA Spec 3.2.4 & 3.2.5 · Relational and Boolean operations
By the end of this lesson you can:
- Use the relational operators
= ≠ < > ≤ ≥to produce a Boolean result. - Combine conditions with the Boolean operators
AND,ORandNOT. - Write and evaluate combined conditions inside an
IFstatement.
Warm-Up 5 min
Last lesson you used MOD and DIV in calculations. Today the result is not a number but a Boolean — True or False.
Quick starter
Aisyah is 15. For each statement, decide if it is true or false:
age > 12age = 18age ≥ 13 AND age ≤ 19
Reveal the answers
age > 12 is True. age = 18 is False. age ≥ 13 AND age ≤ 19 is True — both parts hold, so the whole condition is True.
Key Concept — relational and Boolean operators 14 min
A relational operator compares two values and produces a Boolean result — either True or False.
| Operator | Meaning | Example (True) |
|---|---|---|
= | Equal to | 5 = 5 |
≠ | Not equal to | 5 ≠ 3 |
< | Less than | 3 < 5 |
> | Greater than | 5 > 3 |
≤ | Less than or equal to | 5 ≤ 5 |
≥ | Greater than or equal to | 5 ≥ 3 |
Combining conditions: AND, OR, NOT
A Boolean operator combines or reverses Boolean values to build bigger conditions.
AND— True only when both sides are True.OR— True when at least one side is True.NOT— reverses the value: True becomes False, and the reverse.
How the operators evaluate for inputs A and B:
| A | B | A AND B | A OR B | NOT A |
|---|---|---|---|---|
| False | False | False | False | True |
| False | True | False | True | True |
| True | False | False | True | False |
| True | True | True | True | False |
Worked Example — is the age a teenager? 12 min
Problem: input an age and output 'Teenager' if it is between 13 and 19 inclusive. Otherwise output 'Not a teenager'.
A teenager satisfies two conditions at once, so we join them with AND.
AQA pseudo-code
age ← USERINPUT
IF age ≥ 13 AND age ≤ 19 THEN
OUTPUT 'Teenager'
ELSE
OUTPUT 'Not a teenager'
ENDIFWe can also write the opposite test with NOT. This outputs a warning when the visitor is not an adult:
age ← USERINPUT
IF NOT (age ≥ 18) THEN
OUTPUT 'Under 18'
ENDIFFor age = 15, the test age ≥ 18 is False, so NOT (False) is True and the message is shown.
The same algorithm in Python
age = int(input("Enter age: ")) if age >= 13 and age <= 19: print("Teenager") else: print("Not a teenager") if not (age >= 18): print("Under 18")
In Python, the operators are and, or, not, with == for equal and != for not equal.
Try It Yourself 12 min
Goal: Write a condition that is True when a temperature is below 18.
Hint: one relational operator is enough — use <.
Goal: Write pseudo-code that inputs a mark and outputs 'Merit' when the mark is at least 60 and at most 79.
Hint: join mark ≥ 60 and mark ≤ 79 with AND inside an IF.
Goal: Write a condition that is True when a day is 'Saturday' or 'Sunday', then write the same test using NOT for a weekday.
📝 Exam Practice 10 min
Answer the way the examiner expects — the command word and the marks tell you how much to write.
State whether (5 > 3) AND (2 > 4) is True or False.
Mark scheme
- False (1) —
5 > 3is True but2 > 4is False, andANDneeds both True.
Write a condition that is True when score is between 50 and 100 inclusive.
Mark scheme
- Uses
ANDto join two comparisons (1). score ≥ 50 AND score ≤ 100— both bounds inclusive (1).
State the result of each expression: (3 = 3) OR (1 > 9) and NOT (4 ≤ 4).
Mark scheme
(3 = 3) OR (1 > 9)is True (1) —ORneeds only one True side.NOT (4 ≤ 4)is False (1) —4 ≤ 4is True, andNOTreverses it.
Recap & Key Terms 3 min
Relational operators = ≠ < > ≤ ≥ compare values and give a Boolean. Boolean operators AND, OR and NOT combine those Booleans into bigger conditions — most often inside an IF.
- Relational operator
- An operator that compares two values and returns a Boolean, such as
<,≥or≠. - Boolean operator
- An operator that combines or negates Boolean values:
AND,OR,NOT. - AND
- True only when both conditions are True.
- OR
- True when at least one condition is True.
- NOT
- Reverses a Boolean — True becomes False and the reverse.
Homework 1 min
Task (≤ 15 min): Write, in AQA pseudo-code, an algorithm that inputs an age and outputs 'Child fare' when the age is under 5 or 60 and over, otherwise 'Full fare'.
Model answer
age ← USERINPUT
IF age < 5 OR age ≥ 60 THEN
OUTPUT 'Child fare'
ELSE
OUTPUT 'Full fare'
ENDIFAward marks for: read the input (1), a correct condition using OR with < and ≥ (1), the correct output on each branch (1).