KS3 · Computer Science
Selection: making decisions in code
A theme park ticket program charges a 9-year-old 18 and a 14-year-old 25. Same program. How? It asks one question about age, gets True or False, and follows one path.
Computer Science · Selection
The ticket program’s fork
One visitor, aged 9. Step through and watch which price lights up, and which one stays dark.
Make a call before you press Next: does a 9-year-old pay 25 or 18?
Output
Step 1: The ticket program starts.
Press Next and follow the lit path. Keep one eye on the other price box.
Computer Science · Conditions
Make the call: True or False?
Pick a card, then pick its box. Commit first, then read why. Watch the pairs that use the same numbers.
Still to sort
Evaluates to True (0)
The comparison holds for those values.
Where the line is: When the two values are equal, >= and <= give True but > and < give False.
Evaluates to False (0)
The comparison does not hold for those values.
Where the line is: False is a proper result, not an error. It’s what sends a program down its other path.
A condition is a question your program can answer with True or False. Each card gives you a variable’s value and a condition. Your job: decide which.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
What you need to know
- Selection is for when a program has more than one possible path: it checks a condition and picks one.
- A condition is an expression that evaluates to True or False. With age = 9, age > 12 is False.
- Relational operators compare two values: == equal to, != not equal to, <, <=, > and >=.
Have a goA ride needs height >= 120. Priya is exactly 120 cm. Does height >= 120 evaluate to True or False for her?
True. She gets on.
>= means greater than OR equal to, so 120 counts. Answering False treats >= as if it were >, which needs the value to be bigger.
- In a flowchart, selection is a decision symbol with a True path and a False path coming off it.
- In Python, the if block runs when the condition is True, and the else block runs when it is False.
- Only one of those two blocks runs. You need both if and else when there are two possible paths.
- Watch the equals signs: = assigns a value to a variable, == compares two values.
Have a goYour mate types if lives = 0: and declares Python is broken. Is Python to blame?
No. It should be if lives == 0:
A single = stores a value, so it can’t ask a question. == compares and gives True or False, which is what an if needs.
- Python’s rules for if and else: lowercase, a colon after each, and the code inside indented.
- and needs both conditions True, or needs at least one, and not flips True to False and back.
Have a gois_raining is True and is_cold is False. What does is_raining or is_cold give? And is_raining and is_cold?
or gives True; and gives False.
or only needs one True, so it’s True. and needs both True, and is_cold is False, so it’s False. Mixing them up flips both answers.
- Selection is one of the three main control structures, alongside sequence and iteration.
The big picture
Selection is how a program chooses. It checks a condition, gets True or False, and runs one path. In Python that's if and else, and only one of the two blocks ever runs.
Key points
Worked example
Problem
A program has a variable called user. Write Python that outputs "Welcome back" if user is equal to the string "Alex", and outputs "Please sign up" if it is not.
⚠ Watch out
Two classic slips. One: writing = when you mean ==. = is assignment, so if pin = 1234: is a syntax error. Two: thinking the if block and the else block both run. They don't. True or False picks exactly one.
Memory hook
One equals puts it in. Two equals asks the question.
Check yourself
age is 12. What does age > 12 evaluate to? What does age >= 12 evaluate to? Which of the two would send a program down its if block?
Flashcards
(14)What is selection?
What is a condition?
What is a relational operator?
In a flowchart, what shows selection?
In Python, when does the else block run?
What is the difference between = and == in Python?
Which operator means “not equal to”?
What does >= mean?
Which Python rules apply to if and else syntax?
When is A and B True?
When is A or B True?
What does not do?
Name the three main control structures.
What does iteration do?
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 KS3 Computer Science topics
How this lesson was checked. This KS3 Computer Sciencelesson 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 27 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.