CASE as if/elif/else in Python
Python has no CASE, so write it as an if/elif chain testing the same variable. The first value uses if, each other value uses elif, and OTHERWISE becomes else.
Understanding CASE as if/elif/else in Python in IGCSE Computer Science Paper 2
What it does: The first CASE value starts the chain with if, and Python uses == to compare Move with the value. A CASE statement checks one variable, so each extra value is an elif comparing that same variable. A comparison in Python uses ==. A single = is assignment and causes a syntax error here. OTHERWISE becomes else:. Python has no otherwise keyword. else has no condition after it. It is just else: and it catches every value not matched above.
Common mistakes: A single = assigns a value. To test whether move equals "L" you need the comparison operator ==, so the line should be if move == "L":. Every if line in Python must end with a colon. The line should be if move == "F":.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 188–213) and word search (Modules 188–231).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
if/elif/elseFill in the Blanks
Spot the Error
Student with a class code? Join your class →