elif Statements, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
elif Statements in one minute
What students need to know
elif is checked only if the previous if was False. elif can use any comparison operator including ==.
elif is short for 'else if' — it adds another condition to check. x > 10 is False, so Python checks elif — 5 > 3 is True, so 'Medium' prints.
Mistakes students make
- Python uses elif, not 'else if' (no space).
- elif cannot appear without an if statement before it.
- Missing colon at the end of the elif line.
- elif must be lowercase — Elif is not valid Python.
PREVIOUS · MODULE 14If Statements
YOU ARE HERE · MODULE 15elif Statements
NEXT · MODULE 16else Statements
What students will learn in this module
Every question in Module 15
Quick questions
- What does elif stand for?Aelse in functionBelse if
- When does an elif block run?AWhen the if above is False and elif is TrueBAlways
- x = 5\nif x > 10:\n print('Big')\nelif x > 3:\n print('Medium')\nWhat prints?AMediumBBig
- Can you have multiple elif blocks?ANoBYes
- Can elif appear before if?ANo if must come firstBYes
Key terms
Students type the meaning of:
elifChainingFirst match winsCondition order
Match the pairs
else if x > 5:
print('mid')Match it to what it doeselif x > 5
print('mid')Match it to what it doesif x > 10:
print('big')
elif x > 5:
print('mid')Match it to what it doeselif score == 100:
print('perfect')Match it to what it doesx = 7
if x > 10:
print('big')
elif x > 5:
print('mid')Match it to what it doesx = 15
if x > 10:
print('big')
elif x > 5:
print('mid')Match it to what it doesFill in the blanks
if x > 10: print('Big') ____ x > 5: print('Medium')if score >= 90: print('A') elif score >= 80_ print('B')if age >= 18: print('Adult') ____ age >= 13: print('Teen')if temp >= 35: print('Hot') elif temp __ 25: print('Warm')if day == 'Monday': print('Start') elif day __ 'Saturday': print('Weekend')
Spot the error
Question 1
Aif x > 10:B print('Big')Celse if x > 5:D print('Medium')
Question 2
Ax = 7Belif x > 5:C print('Medium')
Question 3
Aif x > 10:B print('Big')Celif x > 5D print('Medium')
Question 4
Aif x > 10:B print('Big')CElif x > 5:D print('Medium')
Question 5
Aif x > 10:B print('Big')Celif x > 5:Dprint('Medium')
