GCSE · Computer Science · AQA · Spec 8525
Selection
Same code. Three different inputs. Three different outputs. The trick is a tiny question the program asks before it does anything: true or false?
Computer Science · Programming
Same code, different path
One tiny guessing program: if number == 7, print "You got it!"; elif number < 7, print "higher"; else, print "lower". Follow it when you type 3.
Before you press Next: you type 3. Which message will it print?
1 number = int(input())2 if number == 7:3 print("You got it!")4 elif number < 7:5 print("higher")6 else:7 print("lower")8 print("Done")
Variables
Output
Step 1: You type 3, so number holds 3. Nothing has been decided yet. Press Next and watch where your 3 sends the program.
Press Next to step through the program. The highlighted line is the one being run. A block whose line never lights up never ran.
Computer Science · Programming
True, false, or not a comparison?
In Python, suppose age is 12. Pick a line, then pick where it belongs.
Still to sort
Evaluates to true (0)
The comparison is correct for age = 12.
Evaluates to false (0)
The comparison is wrong for age = 12.
Not a comparison: it's assignment (0)
It stores a value instead of asking a question.
Where the line is: In Python, a double == compares two values and a single = puts a value into a variable (other languages and pseudocode can use different symbols).
Computer Science · Algorithms
Trace table — dry run the code
One nested program, three values of mark. Watch which conditions get checked, and which never do. A blank cell means that condition was never checked.
Ready when you are — step through one line at a time.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
How a program asks a true-or-false question and follows just one path.
What you need to know
- Selection is for when a program has more than one possible path. It checks a condition, an expression that is true or false.
- In a flowchart, the condition goes inside a diamond. Its true and false arrows lead to the two paths.
- In Python, if comes first: the condition, a colon, then an indented block of code that runs only when it's true.
- Add else, with its own colon and indented block, for the other path. You need an if and an else for two paths.
Have a gonumber is 3. The code says: if number > 5, add 5 to number; else take 5 away. What is number afterwards?
-2
3 > 5 is false, so the if block is skipped and the else block runs: 3 - 5 = -2. With if and else, one of the two blocks runs.
- For three or more options, use if, elif and else. The conditions are checked one by one and the first true one runs.
- Use as many elif blocks as you need. The else block is optional: leave it out and, if nothing is true, no block runs.
Have a goA chain has no else: if x < 5, then elif x < 10. What runs when x is 20?
Nothing. No block runs.
Both conditions are false, and with no else there is no other path to follow, so the program skips the whole chain.
- A false condition's block is skipped. The program tries the next elif or else; with none left, it carries on after the selection.
Have a goSam bets you a biscuit that programs always run every line. score is 20 and print("Bonus") sits inside if score > 30. Does Bonus print?
No. Bonus is skipped, so Sam owes you a biscuit.
20 > 30 is false, so the block is skipped. Selection lets a program skip lines instead of running them all.
- Relational operators compare two values: ==, !=, <, <=, >, >=. In Python, == checks for equal, while a single = assigns.
- Common errors with selection are missing colons and wrong indentation.
- Nested selection puts one selection block inside another. The inner condition is checked only if the main condition is true.
The big picture
Selection lets a program choose between paths. A condition, an expression that is true or false, decides which block runs. Use if for one block and else for the other path, or if, elif and else for three or more options, where the conditions are checked one by one and the first true one runs. Relational operators build conditions: == compares and a single = assigns. Selection blocks can be nested, and missing colons and wrong indentation are common errors.
Key points
Worked example
Problem
A speed checker runs: if speed > 70, print "Too fast"; elif speed == 70, print "On the limit"; else, print "Fine". What does it print when speed is 70?
⚠ Watch out
Thinking a program always runs every line from top to bottom. A program does follow a sequence, but selection lets it skip lines: only the block whose condition is true runs (in if/elif/else, the first true one), and the other blocks are skipped.
Memory hook
The diamond asks, one arrow answers: a condition is true or false, and only the path it picks runs.
Check yourself
Cover the page. Can you say how a condition picks the path, write if, elif and else with their colons and indented blocks, and explain what happens to the blocks that don't run?
Flashcards
(14)What is selection used for?
What is a condition?
Which flowchart symbol holds a condition?
What must follow the condition in a Python if statement?
Which keyword gives the code for the other path?
When do you use elif?
Is else compulsory in if/elif/else?
What happens to a block whose condition is false?
Name the six relational operators.
What is the difference between == and = in Python?
Name two common errors with selection statements.
What is nested selection?
When is the inner condition of a nested selection checked?
True or false: a program always runs every line.
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 AQA GCSE Computer Science topics
How this lesson was checked. This AQA GCSE Computer Science (specification 8525)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 13 November 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.