Year 10 · Original DASKEREL study pack · Academic review pending
Selection, conditions and safe branching
Allow up to 55 minutes for reading, practice and review · Source route: Oak AQA Computer Science · DASKEREL teaching requires board review
DASKEREL wrote this resource using the Oak National Academy unit sequence as a curriculum reference. It is a study pack, not a complete unit or an exam-board-approved course. Academic review remains pending.
You will learn to
- Construct mutually exclusive branches for a set of rules.
- Use Boolean expressions with clear boundary conditions.
- Trace and test branch execution using representative inputs.
Key terms: selection · condition · Boolean · branch · mutually exclusive
Learn the idea
Selection chooses a path based on a Boolean expression. An if/elif/else chain is evaluated top to bottom; the first true branch runs, so ordering matters when conditions overlap. The else branch covers all remaining cases, including unintended ones unless input validation comes first.
Translate a rule into explicit comparisons. ‘At least 60’ means >= 60; ‘greater than 60’ means > 60. A range such as 0 through 100 inclusive requires both >= 0 and <= 100. Test the exact boundary and its neighbours.
For categories that must not overlap, start with invalid values, then test highest thresholds first. For a mark scheme with distinction >= 80, merit >= 60 and pass >= 40, checking >= 40 first would wrongly classify a mark of 85 as pass.
A branch should be auditable: list the input, the truth value of each tested condition and the chosen output. This is useful for accessible software and for explaining a program decision to a user.
Worked example
Design a classification for a mark: invalid outside 0–100; distinction 80–100; merit 60–79; pass 40–59; below pass 0–39.
- Check mark < 0 or mark > 100 first; output invalid and stop.
- Otherwise test mark >= 80 and output distinction if true.
- Otherwise test mark >= 60, then mark >= 40.
- Use else for below pass; it now contains only 0–39 because validation already happened.
- Trace 80, 79, 60, 39 and 101 to verify each boundary.
The ordering yields one correct label for every integer input; 101 is rejected rather than labelled distinction.
Try together
A cinema ticket is child for age 0–15, adult for 16–64 and senior for 65 or older. Reject negative ages. State branch order and classify ages -1, 15, 16 and 65.
- Validate before category selection.
- Use <= 15 then <= 64; the remaining valid ages are senior.
- Check transition points exactly.
Show guided answer
if age < 0: invalid; elif age <= 15: child; elif age <= 64: adult; else: senior. Results: invalid, child, adult, senior.
Practise independently
- A program first tests score >= 40, then score >= 70. What is wrong when score = 85?
Show answer and reasoning for question 1
It takes the first branch and never reaches the >= 70 branch; check >= 70 first. The conditions overlap, and an if/elif chain only executes the first true branch.
- Write a Boolean condition for a valid month number and list boundary tests.
Show answer and reasoning for question 2
month >= 1 and month <= 12; test 0, 1, 12 and 13. Both ends are inclusive; immediate outside values expose comparison mistakes.
- A scheme accepts people aged at least 18 but under 70. Write the Boolean eligibility condition and four useful boundary tests.
Show answer and reasoning for question 3
age >= 18 and age < 70; test 17, 18, 69 and 70. 18 and 69 are included; 17 and 70 are excluded. This distinguishes inclusive and exclusive boundaries.
DASKEREL exam-style practice · 6 draft marks
This original practice task and guidance are not an official examination-board paper or mark scheme.
A delivery app charges £4 for orders below £25, £2 for £25–£49.99 and £0 for £50 or more. Negative totals are invalid. Write an ordered selection algorithm and state the charge for -1, 24.99, 25, 49.99 and 50.
Show draft mark guidance
- Reject a total < 0 before pricing (1).
- Test < 25 and assign £4 (1).
- Test < 50 next and assign £2 (1).
- Use else to assign £0 (1).
- Give charges invalid, £4, £2, £2, £0 in order (1).
- Explain why equality at £25 and £50 moves to the next price band (1).
Check your understanding
- elif conditions are not all evaluated after one branch succeeds.
- ‘At least’ includes the threshold value.
- An else branch is safe only if earlier validation excludes impossible inputs.
Retrieve later: Explain why threshold checks in an if/elif chain often run from highest to lowest.
Next step: Combine selection with iteration and test a program that classifies an entire list of inputs.
Library links: Oak National Academy · Programming: selection (checked 2026-11-06) · DASKEREL subject library. Oak's applicable post-2022 content licence is OGL v3.0; some source assets have separate third-party rights. No Oak media is embedded here. DASKEREL is not affiliated with Oak.