Community resourceWorksheet
1CP2-CT-2.4 Multi-branch selection and readable code
Part 4 of 8 · 1CP2-CT-2 · Selection, strings and while loops
The multi-branch worksheet, where the order of the conditions becomes the thing that decides whether a program is right.
Students will:
- order thresholds in an if-elif-else chain correctly
- explain the logic error a wrongly ordered chain produces
- say what happens after one condition in a chain is true
- choose between a chain and nested selection
- improve the readability of a working but unclear program
Inside: 7 explanation cells, 3 multiple-choice questions, 2 Python tasks, 1 fill-in-the-blanks cell and 2 written answers. 20 marks, about 45 minutes.
Series: 1CP2-CT-2 · Selection, strings and while loops, part 4 of 8.
Shared by Coding PathwayVerified teacher
- 15 cells
- About 45 minutes
- CC BY-SA 4.0
- Shared 17 Aug 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Multi-branch selection and readable code
Use if–elif–else when exactly one of several ordered alternatives should run. Python tests conditions from top to bottom and stops at the first true branch.
1. Order broad thresholds carefully
To classify a mark:
if mark >= 70:
grade = "Distinction"
elif mark >= 50:
grade = "Pass"
else:
grade = "Not yet"
A mark of 78 satisfies both >= 70 and >= 50, but the first true branch wins. Put the highest threshold first.
- Distinction
- Pass
- Not yet
- two outputs
Explain the logic error if mark >= 50 is tested before mark >= 70 in the same chain.
Use a mark such as 78 and the first-true-branch rule.
Students type their answer here.
2. Readability supports correctness
Pearson expects meaningful identifiers, indentation, comments where they clarify purpose, and sensible white space. These do not replace correct logic, but they help a programmer follow, test and maintain it.
Prefer ticket_price to x; align every statement in the same block; and comment the reason for an unusual rule rather than narrating obvious syntax.
Which comment adds the most useful information?
- A`# if statement` above an if statement
- B`# add one` above `count = count + 1`
- C`# Under-12s use the junior price` above the age rule
- D`# print` above a print statement
3. Complete an ordered chain
Create category from integer age: Adult for 18 or above, Teen for 13–17, otherwise Child. Output only the category.
age = 15
# Create category and output it.
4. Independent multi-branch program
Input integer items. Set delivery to Large van for 50 or more, Small van for 20–49, and Bike otherwise. Output only delivery. It will be tested at 50, 20 and 19.
# Input items, classify delivery, and output it.
5. Nested selection
A nested if sits inside another branch. Use it only when the second decision is relevant after the first. Excessive nesting makes code harder to follow; a well-ordered elif chain is clearer for mutually exclusive thresholds.
Which structure best classifies one score into Bronze, Silver or Gold?
- AThree unrelated if statements
- BOne if–elif–else chain
- CA while loop containing an if
- DAn input statement for each category
Give two readability improvements for code that uses variables a and x, inconsistent indentation, and a comment # code.
State each improvement and how it helps a reader.
Students type their answer here.
In an if–elif–else chain, what happens after one condition is true?
- AEvery later condition is still tested.
- BOnly the else branch runs as well.
- CThe remaining branches are skipped.
- DThe program returns to the first condition.
Route forward
You can now design ordered, readable multi-branch selection. Next, logical operators combine or reverse conditions without unnecessary nesting.