GCSE · Computer Science · Eduqas · Spec C500QS
Selection in programs
Same code, four different inputs, four different paths. Which lines run, and which get jumped over?
Computer Science · Selection
Follow the input through the code
Same program, four inputs. Call each step before it appears.
Choose an input, step through the program, and call each result before it appears.
score = int(input("Score out of 10: "))if score == 10:print("Perfect")elif score >= 5:print("Pass")else:print("Retry")print("Next question")
Variables
Step 1. The program asks for a score. 7 is typed in and stored in score.
Ask yourself two things at every condition: is it True or False, and which line runs next?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
How a program picks one path through its code, and skips the rest.
What you need to know
- Selection is used when a program has more than one possible path to follow.
- A condition is an expression that works out to True or False.
Have a goPriya insists that the condition 10 > 3 is 'kind of True, kind of False'. Is she right?
No. 10 > 3 is True.
A condition always works out to exactly one of True or False, so there is no 'kind of'.
- The program checks the condition, then picks the path: a block of code only runs if its condition is True.
- In the Python-style code here, you write if, a condition and a colon, then an indented block of code underneath.
- Add else with its own colon and indented block, and code can run on either of the two paths.
Have a goA program says: if weight <= 20: print("OK"), else: print("Pay extra"). The weight is 25. Which line prints?
Pay extra
25 <= 20 is False, so the if block is skipped and the else block is the path that runs.
- The double equals, ==, is a comparison operator that checks whether one value is equal to another.
- For three or more options, add elif. The program checks the conditions one by one and picks the first True one.
- You can use several elif blocks, and the else and its block are optional.
Have a goA program has an if and an elif but no else, and both conditions are False. Can neither block run?
Yes. Neither block runs and the program carries on.
Without an else there is no fallback path, so when every condition is False nothing in the selection runs.
- The blocks that were not picked are skipped, and execution carries on at the line after the selection.
- In a flowchart, the decision symbol is a diamond holding the condition, with arrows labelled True and False.
The big picture
Selection lets a program follow more than one possible path. It checks a condition that is True or False, runs the block for the first True path, skips the other blocks and carries on at the line after the selection.
Key points
Worked example
Problem
A ride program runs: age = int(input("Age: ")) if age < 13: print("Child fare") elif age < 65: print("Adult fare") else: print("Senior fare") print("Enjoy the ride") The age typed in is 40. Which condition is True first, what is printed, which blocks are skipped, and where does the program go next?
⚠ Watch out
Thinking every block whose condition is True will run, or that the else runs as well. In multi-path selection only the first True condition's block runs, and then the program carries on after the whole selection.
Memory hook
Top to bottom, first True wins, then carry on below.
Check yourself
Cover the page. An if / elif / else gets an input that makes both conditions True. Which block runs, which are skipped, and where next?
Flashcards
(12)What is selection?
What is a condition?
Which statements carry out selection in Python-style code?
What comes after the condition in an if line?
When does the block under an if run?
What does == do in a condition?
When do you need an if and an else together?
What does elif let a program do?
What happens to the blocks that are not picked?
Which parts of if / elif / else are optional?
Which flowchart symbol shows a decision?
What are the two arrows leaving a decision diamond labelled?
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 Eduqas GCSE Computer Science topics
- Lists, tuples and dictionaries
- Mathematical and logical operations in code
- Modular structuring with abstraction
- Presenting test outcomes with commentary
- Program a solution to requirements
- Refining code during development
- Sequence in programs
- String manipulation in code
- Subroutines with well-defined interfaces
- Typical, extreme and erroneous test data
- Understanding revised requirements
- Using a variety of data types
How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)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 16 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.