๐ Python for beginners ยท session 5 of 58 ยท 60 minutes ยท ๐ free with an account
Making decisions: if, elif and else
Programs can choose. With if, elif and else a program checks something and does different things depending on the answer. Practise each kind of decision before building a grade machine, a bill calculator and a game judge.

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-up4 min
- True or False6 min
- if and else8 min
- elif8 min
- and, or, not7 min
- Grade machine7 min
- Electricity bill8 min
- Rock, paper, scissors7 min
- Quiz4 min
- Set the project1 min
By the end you can
- Compare values with == != < > <= >=
- Write if and else with correct indentation
- Choose between many cases with elif
- Combine conditions with and, or and not
Before you start
- Session 3: input() and converting to numbers
Have ready
- This page
- Cards that say YES and NO (optional)
Beginner ยท ages 10 and up
Warm-up ยท think first
A ride says: "You must be at least 120 cm tall." Write the rule as a yes/no question the gate machine asks, and what it does for each answer.
Show the answer
Is height at least 120? Yes: open the gate. No: "Sorry, not yet". Every decision is a yes/no question with an action for each answer.
Teacher tip: Act it out with different heights; ask what happens at exactly 120.
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 Score Code
Run this exact code: score = 7 if score == 10: print('Gold') elif score >= 5: print('Silver') else: print('Try again') Notice which word appears.
- ๐ง
Level 2 ยท Tweak it
Change Score Numbers
In that same score code, change 7 to 3 and change >= 5 to >= 8. Predict Gold, Silver or Try again, then run it.
- ๐ ๏ธ
Level 3 ยท Build it
Build Your Gate
Make your own Python decision for a mini game. Set key = True and energy = 2. Use if, elif, else and one and/or/not to print Open, Wait or Locked. Test two changes.
Part 1 of 4 ยท learn, see, practise
Questions with True or False answers
A comparison gives True or False. == asks "equal?", != "not equal?", and < > <= >= compare sizes.
One = stores a value; two == ask a question.
โถ Output
True False True False
๐ฆ Memory boxes
125intChange height to 120 and predict the first two lines.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
1.1 x = 15. Print whether x is greater than 10, then whether x equals 15.
โถ 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 2 lines the student writes
x = 15print(x > 10)print(x == 15)
What it prints
True True
What โ Check looks for
- it prints exactly:
True True
- With
x = 5, it prints exactly:False False
1.2 a = 7 and b = 7. Print whether they are equal, then whether they are different.
โถ Output
(nothing is printed)
๐ฆ Memory boxes
7intb7int๐งโ๐ซ 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
a = 7b = 7print(a == b)print(a != b)
What it prints
True False
What โ Check looks for
- it prints exactly:
True False
- With
a = 3, it prints exactly:False True
1.3 n = 24. Print whether n is even, then whether n is a multiple of 3.
โถ Output
(nothing is printed)
๐ฆ Memory boxes
24int๐งโ๐ซ 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 = 24print(n % 2 == 0)print(n % 3 == 0)
What it prints
True True
What โ Check looks for
- it prints exactly:
True True
- With
n = 25, it prints exactly:False False
- With
n = 9, it prints exactly:False True
๐ Free for a year
Make a free account to open the rest of this lesson
Every new account opens every lesson of every course free for a whole year: no payment, no card, nothing to cancel.
Unlocking the rest of this lesson gives you:
- Part 2: if and else, with practice at three levels
- Part 3: Many choices with elif, with practice at three levels
- Part 4: and, or, not, with practice at three levels
- Class activity 1: The grade machine
- Class activity 2: Electricity bill
- Class activity 3: Rock, paper, scissors judge
- A 8-question quiz
- After-class project: My quiz game
- Homework and a printable practice sheet with answers
- Teach mode and the minute-by-minute teacher's plan
It takes a minute. Anyone under 13 signs up with a parent. The first 2 lessons of every course, every game and all maths practice stay free.
FAQ
Making decisions: if, elif and else: questions
What is the difference between if, elif and else in Python?
if checks first, elif checks more conditions when earlier ones were False, and else runs when none were True.
Why does Python use indentation?
It shows which lines belong to an if, elif or else.
What is == in Python?
It compares two values and gives True or False; one = stores a value.
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