GCSE · Computer Science · Edexcel · Spec 1CP2
Relational operators
Is a 12-year-old 'over 12'? You'd answer instantly. A program has to ask an exact True-or-False question, and one tiny symbol decides the answer.
Programming · Selection
One point, two different branches
The same program, run twice: first with a score of 10, then with 11. Step through and watch each condition get its True or False answer in the state panel. (< means 'less than'; <= means 'less than or equal to'.)
Before you press Next: which line will print for a score of 10? And for 11? Commit to both, then step through.
1 score = int(input("Score: "))2 if score < 0:3 print("Negative")4 elif score <= 10:5 print("0 to 10")6 else:7 print("Over 10")
Variables
Output
Step 1: Run 1. Someone types 10, so score holds 10. Now the program starts asking questions, from the top, one at a time.
Try to say each True or False yourself before the step shows it.
Relational operators
Words into symbols
Pick a rule, then pick the operator that checks it.
Still to sort
== (0)
Where the line is: == is True only when the two values are exactly the same: 10 == 10 is True.
!= (0)
Where the line is: != is the opposite of ==. It's True whenever the two values are different, so 10 != 10 is False.
< (0)
Where the line is: < leaves the edge value out: 5 < 5 is False, because 5 isn't less than itself.
<= (0)
Where the line is: <= lets the edge value in: 5 <= 5 is True. Read it as 'at most'.
> (0)
Where the line is: > leaves the edge value out: 5 > 5 is False.
>= (0)
Where the line is: >= lets the edge value in: 5 >= 5 is True. Read it as 'at least'.
A program can't read 'no more than 30'. Every rule has to become a comparison between two values that comes out True or False. Pick a rule, then the one operator that checks it.
Predict, then check
Read the condition out loud as a yes-or-no question before you choose.
A club's rule is: everyone aged 12 or over can join. The program checks if age > 12. A 12-year-old tries to join. What happens?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Every if in a program asks a yes-or-no question. Relational operators are how it asks.
What you need to know
- A relational operator compares two values and produces one of just two results: True or False.
- age > 12 compares what's in age with 12. It's False when age is 9, and True when age is 15.
Have a goYour mate is completely sure that when age holds 15, age > 12 gives back 15. What does it really give back?
True.
A comparison never hands back one of its values. 15 is greater than 12, so the result is simply True.
- == means equal to, and != means not equal to.
- < is less than and > is greater than. Both leave the edge value out.
- <= is less than or equal to (at most), and >= is greater than or equal to (at least). Both let the edge in.
Have a goNo pen needed: is 20 >= 20 True or False? And what about 20 > 20?
20 >= 20 is True; 20 > 20 is False.
A number is never greater than itself, so > leaves 20 out. >= also accepts 'equal', so 20 gets in.
- So 10 == 10 and 10 >= 10 are True, 10 != 10 is False, 12 <= 13 is True, 5 > 10 is False.
- In Python, == compares two values and a single = assigns a value. Other languages may use different symbols for these jobs.
Have a goTwo lines: lives = 3 and lives == 3. Which one puts 3 into lives, and which one asks a True or False question?
lives = 3 puts 3 in; lives == 3 asks the question.
It's tempting to read both as 'equals', but in Python one = assigns a value and two == compare two values.
- A condition is an expression that's True or False. Selection uses it: if number > 5, add 5 to number; else, subtract 5.
- In if / elif / else, conditions are checked in order. The first True one decides the branch; if none is True, the else runs.
The big picture
A relational operator compares two values and hands back True or False. There are six of them: == (equal to), != (not equal to), < (less than), <= (at most), > (greater than) and >= (at least). A comparison like age > 12 is a condition, and conditions steer selection: in an if / elif / else they're checked from the top, and the first True one picks the branch. In Python, == compares while a single = assigns. And the value sitting right on the edge is the one that catches mistakes, because that's where > and >= part ways.
Key points
Worked example
Problem
A lift may only move when there are fewer than 8 people inside. The variable people holds how many are inside. Write the condition that lets the lift move, then check it with 7 people and with 8 people.
⚠ Watch out
Grabbing > when the rule includes its edge. 'At least 50' means 50 counts, but score > 50 is False when score is 50, so a score of exactly 50 gets wrongly turned away. Use score >= 50. The same slip happens with < and <= for 'at most'.
Memory hook
The little line under the symbol lets the edge in: <= and >= include the edge value, < and > shut it out. And one = stores, two == ask.
Check yourself
x holds 7. Without looking back, say whether each is True or False: x != 7, x >= 7, x < 7. Then say which operator you'd use for 'at most 7'.
Flashcards
(11)What does a relational operator do?
Which operator tests whether two values are equal?
Which operator means 'not equal to'?
Which operator means 'less than'?
Which operator means 'at most'?
Which operator means 'more than'?
Which operator means 'at least'?
In Python, what's the difference between = and ==?
What is a condition?
In if / elif / else, which branch runs?
Which value is the most useful one to test a condition with?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Edexcel GCSE Computer Science topics
How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 26 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.