Selection: if, elif and else
Selection lets a program make decisions. Python checks conditions from the top and runs the first block that is True.
if, elif, else
else runs if none of them is True.
The colon and the indentation show which lines belong to each block.
mark = 72
if mark >= 70:
print("A")
elif mark >= 50:
print("B")
else:
print("C")
Combining conditions
if age >= 13 and age <= 19: is True only for teenagers.
if day == "Sat" or day == "Sun": is True at weekends.
Nested selection
Always test the boundaries: what happens at exactly 70 or 50?
What does the grade program print when mark = 50?
- mark >= 70 is False.
- mark >= 50 is True, so print B and skip the rest.
Answer: B
if, elif and else choose which block runs; only the first True branch runs. Conditions use == != < > <= >= with and, or, not. Indentation shows the blocks.
- Selection
- Choosing which code runs using a condition, such as if, elif and else.
- 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.
What does this print?
mark = 64
if mark >= 70:
print("A")
elif mark >= 50:
print("B")
else:
print("C")Show the answer
Answer: B
64 >= 70 is False, but 64 >= 50 is True, so B is printed.
What does this print?
mark = 85
if mark >= 70:
print("A")
elif mark >= 50:
print("B")
else:
print("C")Show the answer
Answer: A
85 >= 70 is True, so A is printed.
Check you have got it
Answer 6 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, topic 6.2.2, 6.5.2, 6.5.3
- Pearson Edexcel International GCSE Computer Science (4CP0) specification, topic 2.2.2, 2.5.2, 2.5.3
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? →