📁 Paper 1 · 3.2 Programming
3.2.2b Selection
AQA 8525 · GCSE Computer Science · ~10 min read
Notes
──
Video
──
Worksheet
──
Quiz

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

OperatorMeaningExample
ANDBoth conditions must be Trueage >= 18 AND hasID = True
ORAt least one condition must be Truescore < 0 OR score > 100
NOTReverses the Boolean valueNOT 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
Video coming soon

Key points

  • IF / ELSEIF / ELSE / ENDIF structure in AQA pseudo-code
  • How conditions are evaluated top to bottom
  • Nested IF statements for complex decisions
  • AND, OR, NOT in conditions
Click slide or press arrow keys to navigate
✍️

Worksheet — 3.2.2b Selection

8 questions · 21 marks · Mark schemes on submit

Q1What does a selection statement allow a program to do?[1]
✅ Mark scheme
Mark scheme
Makes decisions / executes different code depending on whether a condition is True or False [1].
Q2Write AQA pseudo-code to check if a number is positive, negative, or zero and output the result.[4]
✅ Mark scheme
Mark scheme
IF n > 0 THEN OUTPUT "Positive" [1]; ELSEIF n < 0 THEN OUTPUT "Negative" [1]; ELSE OUTPUT "Zero" [1]; ENDIF [1].
Q3What is the output of this code when score = 75? IF score >= 80 THEN OUTPUT "A" ELSEIF score >= 70 THEN OUTPUT "B" ELSE OUTPUT "C" ENDIF[1]
✅ Mark scheme
Mark scheme
B [1] — 75 is not ≥ 80 so first branch skipped; 75 ≥ 70 so ELSEIF executes.
Q4Write an IF statement that outputs "Valid" if age is between 0 and 120 inclusive.[3]
✅ Mark scheme
Mark scheme
IF age >= 0 AND age <= 120 THEN [1+1 for both conditions with AND]; OUTPUT "Valid" [1]; ENDIF.
Q5What is the difference between IF/ELSE and ELSEIF? Give an example showing when you would use ELSEIF.[3]
✅ Mark scheme
Mark scheme
IF/ELSE handles two outcomes [1]; ELSEIF allows multiple/chained conditions to be tested [1]; e.g. grading A/B/C/D where more than two outcomes exist [1].
Q6Identify and correct the two errors in this code: IF x > 10 THEN OUTPUT "Big" ELSE IF x > 5 THEN OUTPUT "Medium" END[2]
✅ Mark scheme
Mark scheme
ELSE IF should be ELSEIF (one word) [1]; END should be ENDIF [1].
Q7Write nested IF pseudo-code: if a user is over 18 AND has a ticket, output "Enter". If over 18 but no ticket, output "Buy ticket". Otherwise output "Too young".[5]
✅ Mark scheme
Mark scheme
IF age > 18 THEN [1]; IF hasTicket == True THEN [1]; OUTPUT "Enter" [1]; ELSE OUTPUT "Buy ticket" [1]; ENDIF; ELSE OUTPUT "Too young"; ENDIF [1].
Q8What does NOT do in a condition? Give an example.[2]
✅ Mark scheme
Mark scheme
NOT reverses/negates a Boolean value [1]; e.g. NOT passed evaluates to True when passed = False [1].
Check your answers above.
Topic Quiz
Q 1 of 10
You scored
out of 10
Card 1 of 5
Click to flip
🎉
All done!
TermDefinition
🎯

Mini Test — 3.2.2b Selection

Timed exam conditions.

  • 8 questions · 10 minutes
  • 5 MCQ + 3 short answer
← 3.2.2a Variables & Operators
11 of 57 · AQA 8525
3.2.2c Iteration →