🛰️ Python, Grade 8 · session 2 of 16 · 60 minutes · free
Input and decisions: if, elif, else
NOVA can now ask questions and decide what to do with the answers. You will build ticket machines, grade calculators and a quiz show, and the last tasks of every part mix in maths and f-strings from lesson 1.

A complete lesson · 60 minutes
Teach it, see it, practise it, all on this page.
Open this page with your learner and work down it, or press Teach this lesson to go through it one step at a time on a big screen. Every section has something to do.
- Warm-up3 min
- Warm-up games5 min
- input()9 min
- if, elif, else9 min
- and, or, not9 min
- Ticket machine7 min
- Grade calculator7 min
- Quiz show5 min
- Quiz5 min
- Set the after-class project1 min
By the end you can
- Ask the user with input() and turn the answer into a number with int() or float()
- Compare with == != < > <= >=
- Choose between several paths with if, elif and else
- Combine conditions with and, or and not
Before you start
- Variables, maths and f-strings (lesson 1)
Have ready
- A computer or tablet with this page open
Grade 8 · ages 13 and 14 · no experience needed
Warm-up · think first
A cinema charges 100 rupees for under-12s and 200 for everyone else. How much for a family with children aged 8 and 12 and two adults?
Show the answer
700: 100 for the 8-year-old, 200 each for the 12-year-old and the two adults.
Teacher tip: Ask: is a 12-year-old under 12? This is exactly the kind of rule an if statement checks.
🎮 Warm-up games · 5 quick games
Play with Bolt the robot
Five minutes with NOVA, the station computer. Vote, say why, then show the answer.
- Which comparison doesn't belong: 5 > 3, 2 == 2, 7 <= 7, 4 != 4? (5 > 3 · 2 == 2 · 7 <= 7 · 4 != 4)
Answer: 4 != 4 is the odd one: it is False, and the other three are True. - Would you rather pay 15% of 400 rupees or 20% of 300 rupees? (15% of 400 · 20% of 300)
Answer: They are the same: 60 rupees each. - If a number is bigger than 10, it is bigger than 5. (Always · Sometimes · Never)
Answer: Always — Always. Anything above 10 is also above 5. - A number that ends in 5 is odd. (Always · Sometimes · Never)
Answer: Always — Always. Numbers ending in 5 leave 1 when divided by 2. - I am an even two-digit number. My digits add to 7, and my tens digit is 3 more than my ones digit. What am I?
Answer: 52: the even numbers with digits adding to 7 are 16, 34, 52 and 70, and only in 52 is the tens digit 3 more than the ones.
Three levels, like a real engineer
Use it. Tweak it. Build it.
First use what the lesson shows exactly as it is, then change one key thing and see what happens, then make your own.
- 🔒
Level 1 · Use it
Run the age gate
Type the lesson's age-gate program exactly, one line at a time with its indents: the input line, then if with its indented print, then else with its indented print. Run it twice with different ages and notice what each answer does.
- 🔧
Level 2 · Tweak it
Change the Age Limit
In the same age program, change 13 to 18 and 'Teen Club!' to 'Adult Club!'. Predict who gets in, then run it with ages 15 and 20.
- 🛠️
Level 3 · Build it
Build a Snack Bot
Make your own program that asks for a snack name and a number. Use if, elif and else to print different replies. Test it with at least three answers.
🗺️ Play the Lesson QuestThree worlds, one for each level, with short stages that bring back what you miss.
Part 1 of 3 · learn, see, practise
input(): ask the user
From today I can ask questions. input() waits for the person to type, then gives me what they typed. Careful: it always gives me text.
name = input("Your name? ") shows the question, waits, and stores what is typed. The answer is always a string, even if it looks like a number.
To do maths with it, convert: int(input("Age? ")) for whole numbers, float(input("Price? ")) for decimals.
🧑🏫 Teacher: type this live with the class
Welcome aboard
name = input("Your name? ")Run it: the program waits. Type a name in the Input box.
print(f"Welcome aboard, {name}!")Use the answer like any variable.
age = int(input("Age? "))int() turns the typed text into a number we can do maths with.
print(f"In 10 years you will be {age + 10}")Ask: what happens without int()? Try it: an error, text plus number.
▶ Output
(nothing is printed)
📦 Memory boxes
▶ Output
Ticket price? 149.5 How many? 4 Total: 598.00 rupees
📦 Memory boxes
149.5floatcount4inttotal598.0floatChange the numbers in the Input box (one per line) and run again.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
1.1 Ask for a planet with input() and print Next stop: Mars! (with whatever was typed).
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
planet = input("Planet? ")print(f"Next stop: {planet}!")
What it prints when they type Mars
Planet? Mars Next stop: Mars!
What ✓ Check looks for
- When they type
Mars, the last line it prints isNext stop: Mars! - When they type
Venus, the last line it prints isNext stop: Venus! - In the code: Use input().
1.2 Ask for a whole number and print double it.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
n = int(input("Number? "))print(n * 2)
What it prints when they type 21
Number? 21 42
What ✓ Check looks for
- When they type
21, the last line it prints is42 - When they type
5, the last line it prints is10 - In the code: Turn the text into a number with int().
1.3 Ask for the price of one ticket and how many tickets, then print Total: 600 (the price times the number).
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 3 lines the student writes
price = int(input("Price? "))count = int(input("How many? "))print(f"Total: {price * count}")
What it prints when they type 150, 4
Price? 150 How many? 4 Total: 600
What ✓ Check looks for
- When they type
150then4, the last line it prints isTotal: 600 - When they type
99then3, the last line it prints isTotal: 297
1.4 Ask for a temperature in °C (it may have a decimal) and print it in °F to 1 decimal place, like 98.6 F. F = C × 9 / 5 + 32.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 3 lines the student writes
c = float(input("Celsius? "))f = c * 9 / 5 + 32print(f"{f:.1f} F")
What it prints when they type 37
Celsius? 37 98.6 F
What ✓ Check looks for
- When they type
37, the last line it prints is98.6 F - When they type
-40, the last line it prints is-40.0 F - In the code: Use float() so decimals work.
1.5 Mix with lesson 1: ask for a number of minutes and print hours and minutes, like 2 h 15 min.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
m = int(input("Minutes? "))print(f"{m // 60} h {m % 60} min")
What it prints when they type 135
Minutes? 135 2 h 15 min
What ✓ Check looks for
- When they type
135, the last line it prints is2 h 15 min - When they type
59, the last line it prints is0 h 59 min - In the code: Use //.
- In the code: Use %.
1.6 Mix with lesson 1: ask for a whole number and print its last digit and the number without its last digit, like 6 202 for 2026.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
n = int(input("Number? "))print(n % 10, n // 10)
What it prints when they type 2026
Number? 2026 6 202
What ✓ Check looks for
- When they type
2026, the last line it prints is6 202 - When they type
57, the last line it prints is7 5 - In the code: The last digit is n % 10.
Part 2 of 3 · learn, see, practise
if, elif and else
Decisions keep the station safe. If fuel is low, I sound the alarm; else I stay quiet. The lines under the if are indented: that is how I know they belong to it.
if checks a condition: fuel < 50 is either True or False. The indented lines under it run only when it is True; else: catches every other case.
elif means 'else if': Python checks each condition from the top and runs only the first one that is True. Compare with == (equal), != (not equal), <, >, <= and >=.
🧑🏫 Teacher: type this live with the class
Fuel alarm
fuel = 35Store a fuel level.
if fuel < 50:The colon ends the question. Press Enter: the next line is indented.
print("Low fuel: refill!")Four spaces in: this line belongs to the if.
else:Back to the left edge, then else and a colon.
print("Fuel OK")Run it, then change fuel to 80 and run again.
▶ Output
(nothing is printed)
📦 Memory boxes
▶ Output
Score 72: C
📦 Memory boxes
72intgrade'C'strTry 90, 89, 75, 60 and 59. Which line runs each time? Only the first True one.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
2.1 Print even if n is even, otherwise odd.
▶ Output
(nothing is printed)
📦 Memory boxes
7int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 4 lines the student writes
n = 7if n % 2 == 0: print("even")else: print("odd")
What it prints
odd
What ✓ Check looks for
- it prints exactly:
odd
- With
n = 10, it prints exactly:even
- In the code: Use if.
2.2 Print Freezing if temp is below 0, otherwise Not freezing.
▶ Output
(nothing is printed)
📦 Memory boxes
-3int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 4 lines the student writes
temp = -3if temp < 0: print("Freezing")else: print("Not freezing")
What it prints
Freezing
What ✓ Check looks for
- it prints exactly:
Freezing
- With
temp = 4, it prints exactly:Not freezing
- With
temp = 0, it prints exactly:Not freezing
2.3 Ask for an age. Print child below 13, teen from 13 to 19, adult from 20.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 7 lines the student writes
age = int(input("Age? "))if age < 13: print("child")elif age <= 19: print("teen")else: print("adult")
What it prints when they type 15
Age? 15 teen
What ✓ Check looks for
- When they type
15, the last line it prints isteen - When they type
8, the last line it prints ischild - When they type
20, the last line it prints isadult - When they type
13, the last line it prints isteen - In the code: Use elif for the middle case.
2.4 Print the bigger of a and b using if (no max()).
▶ Output
(nothing is printed)
📦 Memory boxes
14intb9int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 4 lines the student writes
a = 14b = 9if a > b: print(a)else: print(b)
What it prints
14
What ✓ Check looks for
- it prints exactly:
14
- With
a = 3, b = 11, it prints exactly:11
- In the code: Use if.
2.5 Leap years: divisible by 4, but not by 100 unless also by 400. Print leap or not leap.
▶ Output
(nothing is printed)
📦 Memory boxes
2024int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 8 lines the student writes
year = 2024if year % 400 == 0: print("leap")elif year % 100 == 0: print("not leap")elif year % 4 == 0: print("leap")else: print("not leap")
What it prints
leap
What ✓ Check looks for
- it prints exactly:
leap
- With
year = 1900, it prints exactly:not leap
- With
year = 2000, it prints exactly:leap
- With
year = 2023, it prints exactly:not leap
2.6 Mix with lesson 1: over 1000 rupees gets 10% off, otherwise 5% off. Print Pay: 1080.00 with two decimals.
▶ Output
(nothing is printed)
📦 Memory boxes
1200int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 5 lines the student writes
price = 1200if price > 1000: pay = price * 0.9else: pay = price * 0.95print(f"Pay: {pay:.2f}")
What it prints
Pay: 1080.00
What ✓ Check looks for
- it prints exactly:
Pay: 1080.00
- With
price = 800, it prints exactly:Pay: 760.00
- In the code: Use else for the 5% case.
Part 3 of 3 · learn, see, practise
and, or, not
Real rules have more than one part. The airlock opens only if the suit is on and the pressure is safe. I join conditions with and, or and not.
a and b is True only when both are True. a or b is True when at least one is True. not a flips True and False.
Use brackets to make the meaning clear: (day == "Sat" or day == "Sun") and not raining. x in "aeiou" checks whether x is one of those letters.
🧑🏫 Teacher: type this live with the class
Ride check
age = 14Two facts about a rider.
height = 150Height in centimetres.
if age >= 12 and height >= 140:Both must be True, so we use and.
print("You can ride")Indented: runs only when both are True.
else:Every other case.
print("Not this time")Change height to 130 and run again.
▶ Output
(nothing is printed)
📦 Memory boxes
▶ Output
Park day!
📦 Memory boxes
'Sat'strrainingFalseboolChange raining to True, then day to "Mon". Predict before you run.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
3.1 Print yes if x is between 10 and 20 (both included), otherwise no.
▶ Output
(nothing is printed)
📦 Memory boxes
15int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 4 lines the student writes
x = 15if x >= 10 and x <= 20: print("yes")else: print("no")
What it prints
yes
What ✓ Check looks for
- it prints exactly:
yes
- With
x = 25, it prints exactly:no
- With
x = 10, it prints exactly:yes
- In the code: Join the two tests with and.
3.2 Print vowel if letter is a, e, i, o or u, otherwise consonant.
▶ Output
(nothing is printed)
📦 Memory boxes
'e'str🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 4 lines the student writes
letter = "e"if letter in "aeiou": print("vowel")else: print("consonant")
What it prints
vowel
What ✓ Check looks for
- it prints exactly:
vowel
- With
letter = "k", it prints exactly:consonant
- In the code: Use or, or the in trick.
3.3 FizzBuzz for one number: FizzBuzz if n divides by 3 and 5, Fizz by 3 only, Buzz by 5 only, otherwise the number.
▶ Output
(nothing is printed)
📦 Memory boxes
15int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 8 lines the student writes
n = 15if n % 3 == 0 and n % 5 == 0: print("FizzBuzz")elif n % 3 == 0: print("Fizz")elif n % 5 == 0: print("Buzz")else: print(n)
What it prints
FizzBuzz
What ✓ Check looks for
- it prints exactly:
FizzBuzz
- With
n = 9, it prints exactly:Fizz
- With
n = 10, it prints exactly:Buzz
- With
n = 7, it prints exactly:7
3.4 Ask for a password. Print Strong if it has 8 or more characters and is not "password", otherwise Weak.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 5 lines the student writes
p = input("Password? ")if len(p) >= 8 and p != "password": print("Strong")else: print("Weak")
What it prints when they type galaxy2026
Password? galaxy2026 Strong
What ✓ Check looks for
- When they type
galaxy2026, the last line it prints isStrong - When they type
password, the last line it prints isWeak - When they type
abc, the last line it prints isWeak - In the code: len(p) counts the characters.
3.5 Print triangle if each side is shorter than the other two added together, otherwise not a triangle.
▶ Output
(nothing is printed)
📦 Memory boxes
3intb4intc5int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 4 lines the student writes
a = 3b = 4c = 5if a < b + c and b < a + c and c < a + b: print("triangle")else: print("not a triangle")
What it prints
triangle
What ✓ Check looks for
- it prints exactly:
triangle
- With
a = 1, b = 2, c = 5, it prints exactly:not a triangle
- With
a = 2, b = 2, c = 4, it prints exactly:not a triangle
3.6 Mix with lesson 1: hour is on a 24-hour clock. Print it as 2 PM. 0 is 12 AM and 12 is 12 PM.
▶ Output
(nothing is printed)
📦 Memory boxes
14int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 8 lines the student writes
hour = 14if hour == 0: print("12 AM")elif hour < 12: print(f"{hour} AM")elif hour == 12: print("12 PM")else: print(f"{hour - 12} PM")
What it prints
2 PM
What ✓ Check looks for
- it prints exactly:
2 PM
- With
hour = 0, it prints exactly:12 AM
- With
hour = 12, it prints exactly:12 PM
- With
hour = 9, it prints exactly:9 AM
- With
hour = 23, it prints exactly:11 PM
Watch out
Common mistakes
Using = to compare
if x = 5 is an error. Compare with ==.
Forgetting int()
input() gives text, so "5" + 1 fails. Use int(input(…)).
Wrong order of elif
Check the biggest score first. If score >= 60 comes first, a 95 gets a C.
Missing the colon or indent
Every if, elif and else line ends with a colon, and the lines under it are indented.
Class activity 1 of 3
Ticket machine
Ask for the age, then the day (like Sat). Under 12 pays 100 rupees, everyone else 200. Saturday and Sunday cost 50 more. Print the price like Ticket: 150 rupees
- Ask for the age with int(input()).
- Ask for the day with input().
- Set the price from the age with if and else.
- Add 50 if the day is Sat or Sun, then print the ticket.
▶ Output
(nothing is printed)
📦 Memory boxes
Hint
Work out the price in two steps: first from the age, then add the weekend extra.
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 9 lines the student writes
# ===== Ticket machine =====age = int(input("Age? "))day = input("Day? ")if age < 12: price = 100else: price = 200if day == "Sat" or day == "Sun": price = price + 50print(f"Ticket: {price} rupees")
What it prints when they type 10, Sat
Age? 10 Day? Sat Ticket: 150 rupees
What ✓ Check looks for
- When they type
10thenSat, the last line it prints isTicket: 150 rupees - When they type
30thenMon, the last line it prints isTicket: 200 rupees - When they type
14thenSun, the last line it prints isTicket: 250 rupees - When they type
11thenWed, the last line it prints isTicket: 100 rupees - In the code: Check Sat or Sun.
If they're stuck, say
Work out the price in two steps: first from the age, then add the weekend extra.
Class activity 2 of 3
Grade calculator
Ask for a score out of 100. 90 or more is A*, 80 or more A, 70 or more B, 60 or more C, below 60 Retake. Anything below 0 or above 100 is Invalid.
- Ask for the score.
- Check Invalid first.
- Then the grades from the top down with elif.
- Print the grade.
▶ Output
Score? Line 2: EOFError: EOF when reading a line (there is no more input; add lines to the Input box)
📦 Memory boxes
Hint
Put the Invalid check first, so 104 never reaches the A* line.
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 12 lines the student writes
# ===== Grade calculator =====score = int(input("Score? "))if score < 0 or score > 100: print("Invalid")elif score >= 90: print("A*")elif score >= 80: print("A")elif score >= 70: print("B")elif score >= 60: print("C")else: print("Retake")
What it prints when they type 95
Score? 95 A*
What ✓ Check looks for
- When they type
95, the last line it prints isA* - When they type
80, the last line it prints isA - When they type
71, the last line it prints isB - When they type
60, the last line it prints isC - When they type
12, the last line it prints isRetake - When they type
104, the last line it prints isInvalid - When they type
-5, the last line it prints isInvalid
If they're stuck, say
Put the Invalid check first, so 104 never reaches the A* line.
Class activity 3 of 3
Quiz show
Ask two questions: What is 7 * 8? and What is 2 ** 5? Each right answer scores 10. Then print Score: 20/20, and Perfect! if both were right.
- Start score at 0.
- Ask question 1 and add 10 if the answer is 56.
- Ask question 2 and add 10 if the answer is 32.
- Print the score, then Perfect! only for 20.
▶ Output
(nothing is printed)
📦 Memory boxes
0intHint
Use a separate if for each question, so both are always asked.
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 9 lines the student writes
# ===== Quiz show =====score = 0a = int(input("What is 7 * 8? "))if a == 56: score = score + 10b = int(input("What is 2 ** 5? "))if b == 32: score = score + 10print(f"Score: {score}/20")if score == 20: print("Perfect!")
What it prints when they type 56, 32
What is 7 * 8? 56 What is 2 ** 5? 32 Score: 20/20 Perfect!
What ✓ Check looks for
- When they type
56then32, the last line it prints isPerfect! - When they type
56then10, the last line it prints isScore: 10/20 - When they type
54then32, the last line it prints isScore: 10/20 - When they type
1then2, the last line it prints isScore: 0/20
If they're stuck, say
Use a separate if for each question, so both are always asked.
After class · project
Choose-your-path story
Write a short space adventure where the reader makes two choices by typing, and the story ends differently depending on what they chose.
What to make: A story program with at least two questions and three different endings.
Stretch: Keep a score: add points for brave choices and print the score with the ending.
How it is marked
| Look for | Done well when |
|---|---|
| Runs | Every path runs without an error |
| Choices | At least two input() questions |
| Decisions | if, elif and else used correctly |
| Endings | Three or more different endings |
Starter code to take home
Press Copy and paste it into the editor at home, or work on it right here.
▶ Output
The station alarm rings. A meteor is coming! Hide in the lab (a) or fly the shuttle (b)? Line 3: EOFError: EOF when reading a line (there is no more input; add lines to the Input box)
📦 Memory boxes
🔑 Show one possible solution (try it yourself first!)
▶ Output
The station alarm rings. A meteor is coming! Hide in the lab (a) or fly the shuttle (b)? Line 3: EOFError: EOF when reading a line (there is no more input; add lines to the Input box)
📦 Memory boxes
Homework
Practise at home
Each one checks itself. Or print the practice sheet.
1. Ask for a whole number and print positive, negative or zero.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 7 lines the student writes
n = int(input("Number? "))if n > 0: print("positive")elif n < 0: print("negative")else: print("zero")
What it prints when they type 7
Number? 7 positive
What ✓ Check looks for
- When they type
7, the last line it prints ispositive - When they type
-3, the last line it prints isnegative - When they type
0, the last line it prints iszero
2. Ask for two whole numbers and print the smaller one.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 6 lines the student writes
a = int(input("First? "))b = int(input("Second? "))if a < b: print(a)else: print(b)
What it prints when they type 9, 4
First? 9 Second? 4 4
What ✓ Check looks for
- When they type
9then4, the last line it prints is4 - When they type
2then8, the last line it prints is2
3. Mix with lesson 1: ask for seconds and print minutes and seconds, like 2 min 5 s for 125.
▶ Output
(nothing is printed)
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
s = int(input("Seconds? "))print(f"{s // 60} min {s % 60} s")
What it prints when they type 125
Seconds? 125 2 min 5 s
What ✓ Check looks for
- When they type
125, the last line it prints is2 min 5 s - When they type
59, the last line it prints is0 min 59 s
🔥 Challenge round · finished early?
The hardest questions of the lesson, no notes
Cover the notes and try these from memory. They are meant to make you think hard: draw, try small cases, and check your answer.
- Stretch task 1: Mix with lesson 1: ask for a number of minutes and print hours and minutes, like 2 h 15 min.
- Stretch task 1: Mix with lesson 1: ask for a whole number and print its last digit and the number without its last digit, like 6 202 for 2026.
- Stretch task 2: Leap years: divisible by 4, but not by 100 unless also by 400. Print leap or not leap.
- Stretch task 2: Mix with lesson 1: over 1000 rupees gets 10% off, otherwise 5% off. Print Pay: 1080.00 with two decimals.
- Stretch task 3: Print triangle if each side is shorter than the other two added together, otherwise not a triangle.
- Stretch task 3: Mix with lesson 1: hour is on a 24-hour clock. Print it as 2 PM. 0 is 12 AM and 12 is 12 PM.
🧠 Think-hard question
Ask for three numbers and print them in order from smallest to largest, using only if and elif.
Talk it through or use the drawing board. There is more than one way to get there.
Quiz · 8 questions
Final quiz: check what you learned
Pick an answer to see if it is right and why. Your best score is saved on this device.
🖨 Print what we learned
Make a worksheet from this lesson
Pick what to practise, then print it or choose Save as PDF in the print window to download it.
For parents and teachers
The 60-minute lesson plan
Use it as it is, or stretch any part over two sessions. Each row links to the part of the page you need.
| Time | Part | The teacher | The learner |
|---|---|---|---|
| 0–3 min | Warm-up | Ask the question and wait for a guess before any hint. | Guess, then explain. |
| 3–8 min | Warm-up games | Play three or four games. Ask for a reason each time. | Vote and say why. |
| 8–17 min | input() | Type-along first: type each line, say the words, run it. Show the example, then do the puzzle break together before the practice. | Type along, crack the puzzles, then practise. |
| 17–26 min | if, elif, else | Type-along first: type each line, say the words, run it. Show the example, then do the puzzle break together before the practice. | Type along, crack the puzzles, then practise. |
| 26–35 min | and, or, not | Type-along first: type each line, say the words, run it. Show the example, then do the puzzle break together before the practice. | Type along, crack the puzzles, then practise. |
| 35–42 min | Ticket machine | Show the boilerplate and read the numbered steps. Let them press Check often. | Follow the steps. |
| 42–49 min | Grade calculator | Do step 1 together, then let them finish. | Finish the activity. |
| 49–54 min | Quiz show | If time is short, set it as homework. | Try the challenge. |
| 54–59 min | Quiz | Read each question aloud. Vote, then check. | Answer and read why. |
| 59–60 min | Set the after-class project | Open the project and agree a due date. | Copy the boilerplate. |
Questions to ask
- What type does input() give back?
- Why does the order of elif lines matter?
- When do you use and, and when or?
If it feels hard
Draw each decision as a flowchart on paper before typing it. Run every if with two or three values, including the edge case (exactly 13, exactly 0).
If it feels easy
Ask for three numbers and print them in order from smallest to largest, using only if and elif.
FAQ
Input and decisions: if, elif, else: questions
Why does Python need the indentation?
The indent shows which lines belong to the if. Python uses it instead of brackets, so it must be consistent: four spaces.
Start a conversation
Want a teacher to take this class?
Tell us the learner's age and level. A teacher from our network teaches with these lessons; we confirm timing and price first.
- Tell us the learner’s age or grade and goals
- We’ll suggest a suitable class or learning path
- We’ll confirm format, timing and fees with a parent or guardian