What is Selection?
Selection allows a program to make decisions — executing different code depending on whether a condition is True or False. AQA uses IF / ELSEIF / ELSE / ENDIF.
Simple IF Statement
IF score >= 50 THEN
OUTPUT "Pass"
ENDIF
The code between THEN and ENDIF only runs if the condition is True. If the condition is False, the block is skipped.
IF … ELSE
IF score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
The ELSE block runs when the condition is False — exactly one of the two blocks executes.
IF … ELSEIF … ELSE (Multi-way Selection)
grade ← int(INPUT("Enter score: "))
IF grade >= 90 THEN
OUTPUT "A*"
ELSEIF grade >= 80 THEN
OUTPUT "A"
ELSEIF grade >= 70 THEN
OUTPUT "B"
ELSEIF grade >= 60 THEN
OUTPUT "C"
ELSE
OUTPUT "Below C"
ENDIF
Conditions are checked in order — once one is True, that block runs and the rest are skipped. Only the FIRST true condition executes.
Nested IF Statements
An IF can be placed inside another IF block:
IF age >= 18 THEN
IF hasID = True THEN
OUTPUT "Entry allowed"
ELSE
OUTPUT "ID required"
ENDIF
ELSE
OUTPUT "Too young"
ENDIF
Boolean Operators in Conditions
| Operator | Meaning | Example |
| AND | Both conditions must be True | age >= 18 AND hasID = True |
| OR | At least one condition must be True | score < 0 OR score > 100 |
| NOT | Reverses the Boolean value | NOT passed |
IF temp > 30 AND sunny = True THEN
OUTPUT "Perfect beach day"
ENDIF
Exam tip: AQA uses ELSEIF (one word), not ELIF or ELSE IF. Always close with ENDIF. Trace the code carefully — conditions are checked top to bottom and only the first True branch runs.
⚠️ Common Mistakes
- Writing ELSE IF (two words) — AQA uses ELSEIF
- Forgetting ENDIF to close the block
- Using = instead of == for comparison (AQA uses == in conditions)
- Thinking multiple ELSEIF blocks all run — only the first true one executes