Sequence, selection and iteration
If you used Scratch or Python at KS3, you have already used the three building blocks of every program. At GCSE you write and read them in Python.
Sequence
Change the order and you can change the result.
price = 4
qty = 3
total = price * qty
print(total)
Output: 12
Selection
The lines that belong to the if are indented.
temp = 24
if temp > 20:
print("Shorts")
else:
print("Jeans")
Output: Shorts
Iteration
A for loop repeats a set number of times. A while loop repeats while a condition is True.
for i in range(3):
print("Hip hip hooray")
The message is printed 3 times. range(3) gives 0, 1, 2.
What does this program print?
total = 0
for n in range(1, 6):
total = total + n
print(total)
- range(1, 6) gives 1, 2, 3, 4, 5 (it stops before 6).
- total goes 1, 3, 6, 10, 15.
Answer: 15
Sequence: steps in order. Selection: if/else chooses a path. Iteration: for repeats a set number of times; while repeats while a condition is True. Indentation shows which lines belong inside.
- Sequence
- Instructions carried out one after another in order.
- Selection
- Choosing which code runs using a condition, such as if, elif and else.
- Iteration
- Repeating code, or visiting each item of a data structure in turn.
- Indentation
- Spaces at the start of lines showing which code belongs to a block. Python requires it.
All GCSE and International GCSE Computer Science key terms and definitions →
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
A program checks if a number is even and prints "Even" or "Odd". Which construct is this?
- Sequence
- Selection
- Iteration
- Decomposition
Show the answer
Answer: Selection
Choosing a path is selection.
A program prints the numbers 1 to 100 without 100 print lines. Which construct does it use?
- Selection
- Iteration
- Sequence
- Abstraction
Show the answer
Answer: Iteration
A loop repeats the print.
Check you have got it
Answer 7 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.
- Pearson Edexcel GCSE Computer Science (1CP2) specification
- Pearson Edexcel International GCSE Computer Science (4CP0) specification
Facts checked against the sources below, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.
What do exam command words like explain and evaluate mean? →