🛰️ 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.

🎯 Practice mode⚔️ Boss battle🖨 Print a worksheet
Illustration of a cute pastel robot dancing
Illustration: andremsdesign / Pixabay

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.

See the teacher's plan
  1. Warm-up3 min
  2. Warm-up games5 min
  3. input()9 min
  4. if, elif, else9 min
  5. and, or, not9 min
  6. Ticket machine7 min
  7. Grade calculator7 min
  8. Quiz show5 min
  9. Quiz5 min
  10. 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.

More warm-ups for every class →

🎮 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.

  1. 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.
  2. 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.
  3. 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.
  4. A number that ends in 5 is odd. (Always · Sometimes · Never)
    Answer: Always — Always. Numbers ending in 5 leave 1 when divided by 2.
  5. 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.

  1. 🔒

    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.

  2. 🔧

    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.

  3. 🛠️

    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

  1. name = input("Your name? ")

    Run it: the program waits. Type a name in the Input box.

  2. print(f"Welcome aboard, {name}!")

    Use the answer like any variable.

  3. age = int(input("Age? "))

    int() turns the typed text into a number we can do maths with.

  4. print(f"In 10 years you will be {age + 10}")

    Ask: what happens without int()? Try it: an error, text plus number.

Type here

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
Example: run it, then change it

▶ Output

Ticket price? 149.5
How many? 4
Total: 598.00 rupees

📦 Memory boxes

price149.5floatcount4inttotal598.0float

Change 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.

Warm-up

1.1 Ask for a planet with input() and print Next stop: Mars! (with whatever was typed).

Task 1.1

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is Next stop: Mars!
  • When they type Venus, the last line it prints is Next stop: Venus!
  • In the code: Use input().
Warm-up

1.2 Ask for a whole number and print double it.

Task 1.2

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is 42
  • When they type 5, the last line it prints is 10
  • In the code: Turn the text into a number with int().
Core

1.3 Ask for the price of one ticket and how many tickets, then print Total: 600 (the price times the number).

Task 1.3

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 150 then 4, the last line it prints is Total: 600
  • When they type 99 then 3, the last line it prints is Total: 297
Core

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.

Task 1.4

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is 98.6 F
  • When they type -40, the last line it prints is -40.0 F
  • In the code: Use float() so decimals work.
Stretch 🔥

1.5 Mix with lesson 1: ask for a number of minutes and print hours and minutes, like 2 h 15 min.

Task 1.5

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is 2 h 15 min
  • When they type 59, the last line it prints is 0 h 59 min
  • In the code: Use //.
  • In the code: Use %.
Stretch 🔥

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.

Task 1.6

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is 6 202
  • When they type 57, the last line it prints is 7 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

  1. fuel = 35

    Store a fuel level.

  2. if fuel < 50:

    The colon ends the question. Press Enter: the next line is indented.

  3. print("Low fuel: refill!")

    Four spaces in: this line belongs to the if.

  4. else:

    Back to the left edge, then else and a colon.

  5. print("Fuel OK")

    Run it, then change fuel to 80 and run again.

Type here

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
Example: run it, then change it

▶ Output

Score 72: C

📦 Memory boxes

score72intgrade'C'str

Try 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.

Warm-up

2.1 Print even if n is even, otherwise odd.

Task 2.1

▶ Output

(nothing is printed)

📦 Memory boxes

n7int
🧑‍🏫 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.
Warm-up

2.2 Print Freezing if temp is below 0, otherwise Not freezing.

Task 2.2

▶ Output

(nothing is printed)

📦 Memory boxes

temp-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
Core

2.3 Ask for an age. Print child below 13, teen from 13 to 19, adult from 20.

Task 2.3

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is teen
  • When they type 8, the last line it prints is child
  • When they type 20, the last line it prints is adult
  • When they type 13, the last line it prints is teen
  • In the code: Use elif for the middle case.
Core

2.4 Print the bigger of a and b using if (no max()).

Task 2.4

▶ Output

(nothing is printed)

📦 Memory boxes

a14intb9int
🧑‍🏫 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.
Stretch 🔥

2.5 Leap years: divisible by 4, but not by 100 unless also by 400. Print leap or not leap.

Task 2.5

▶ Output

(nothing is printed)

📦 Memory boxes

year2024int
🧑‍🏫 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
Stretch 🔥

2.6 Mix with lesson 1: over 1000 rupees gets 10% off, otherwise 5% off. Print Pay: 1080.00 with two decimals.

Task 2.6

▶ Output

(nothing is printed)

📦 Memory boxes

price1200int
🧑‍🏫 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

  1. age = 14

    Two facts about a rider.

  2. height = 150

    Height in centimetres.

  3. if age >= 12 and height >= 140:

    Both must be True, so we use and.

  4. print("You can ride")

    Indented: runs only when both are True.

  5. else:

    Every other case.

  6. print("Not this time")

    Change height to 130 and run again.

Type here

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
Example: run it, then change it

▶ Output

Park day!

📦 Memory boxes

day'Sat'strrainingFalsebool

Change 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.

Warm-up

3.1 Print yes if x is between 10 and 20 (both included), otherwise no.

Task 3.1

▶ Output

(nothing is printed)

📦 Memory boxes

x15int
🧑‍🏫 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.
Warm-up

3.2 Print vowel if letter is a, e, i, o or u, otherwise consonant.

Task 3.2

▶ Output

(nothing is printed)

📦 Memory boxes

letter'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.
Core

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.

Task 3.3

▶ Output

(nothing is printed)

📦 Memory boxes

n15int
🧑‍🏫 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
Core

3.4 Ask for a password. Print Strong if it has 8 or more characters and is not "password", otherwise Weak.

Task 3.4

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is Strong
  • When they type password, the last line it prints is Weak
  • When they type abc, the last line it prints is Weak
  • In the code: len(p) counts the characters.
Stretch 🔥

3.5 Print triangle if each side is shorter than the other two added together, otherwise not a triangle.

Task 3.5

▶ Output

(nothing is printed)

📦 Memory boxes

a3intb4intc5int
🧑‍🏫 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
Stretch 🔥

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.

Task 3.6

▶ Output

(nothing is printed)

📦 Memory boxes

hour14int
🧑‍🏫 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

  1. Ask for the age with int(input()).
  2. Ask for the day with input().
  3. Set the price from the age with if and else.
  4. Add 50 if the day is Sat or Sun, then print the ticket.
Your code

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
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 10 then Sat, the last line it prints is Ticket: 150 rupees
  • When they type 30 then Mon, the last line it prints is Ticket: 200 rupees
  • When they type 14 then Sun, the last line it prints is Ticket: 250 rupees
  • When they type 11 then Wed, the last line it prints is Ticket: 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.

  1. Ask for the score.
  2. Check Invalid first.
  3. Then the grades from the top down with elif.
  4. Print the grade.
Your code

▶ Output

Score? Line 2: EOFError: EOF when reading a line (there is no more input; add lines to the Input box)

📦 Memory boxes

No variables yet
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 is A*
  • When they type 80, the last line it prints is A
  • When they type 71, the last line it prints is B
  • When they type 60, the last line it prints is C
  • When they type 12, the last line it prints is Retake
  • When they type 104, the last line it prints is Invalid
  • When they type -5, the last line it prints is Invalid

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.

  1. Start score at 0.
  2. Ask question 1 and add 10 if the answer is 56.
  3. Ask question 2 and add 10 if the answer is 32.
  4. Print the score, then Perfect! only for 20.
Your code

▶ Output

(nothing is printed)

📦 Memory boxes

score0int
Hint

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 56 then 32, the last line it prints is Perfect!
  • When they type 56 then 10, the last line it prints is Score: 10/20
  • When they type 54 then 32, the last line it prints is Score: 10/20
  • When they type 1 then 2, the last line it prints is Score: 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 forDone well when
RunsEvery path runs without an error
ChoicesAt least two input() questions
Decisionsif, elif and else used correctly
EndingsThree 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.

Project starter

▶ 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

No variables yet
🔑 Show one possible solution (try it yourself first!)
One possible solution

▶ 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

No variables yet

Homework

Practise at home

Each one checks itself. Or print the practice sheet.

Warm-up

1. Ask for a whole number and print positive, negative or zero.

Homework 1

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is positive
  • When they type -3, the last line it prints is negative
  • When they type 0, the last line it prints is zero
Core

2. Ask for two whole numbers and print the smaller one.

Homework 2

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 9 then 4, the last line it prints is 4
  • When they type 2 then 8, the last line it prints is 2
Stretch 🔥

3. Mix with lesson 1: ask for seconds and print minutes and seconds, like 2 min 5 s for 125.

Homework 3

▶ Output

(nothing is printed)

📦 Memory boxes

No variables yet
🧑‍🏫 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 is 2 min 5 s
  • When they type 59, the last line it prints is 0 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.

🧠 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.

1What does this show?
x = 7
if x > 5:
    print("big")
else:
    print("small")
Show the answer

big. 7 > 5 is True, so only the if line runs.

2What does this show?
print(3 == 3.0)
Show the answer

True. 3 and 3.0 are the same value, so == gives True.

3What does this show?
a = 4
print(a > 2 and a < 4)
Show the answer

False. a < 4 is False when a is 4, so the and is False.

4What does this show?
n = 10
if n % 3 == 0:
    print("A")
elif n % 2 == 0:
    print("B")
else:
    print("C")
Show the answer

B. 10 is not a multiple of 3, but it is even, so the elif runs.

5input() always gives back…
Show the answer

a string (text). Use int() or float() to turn it into a number.

6What does this show?
print(not (5 > 3))
Show the answer

False. 5 > 3 is True, and not flips it to False.

7What does this show?
age = "13"
print(age + "1")
Show the answer

131. age is text, so + joins the two strings.

8What does this show?
x = 0
if x:
    print("yes")
else:
    print("no")
Show the answer

no. 0 counts as False in an if.

🖨 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.

Include
Options

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.

TimePartThe teacherThe learner
0–3 minWarm-upAsk the question and wait for a guess before any hint.Guess, then explain.
3–8 minWarm-up gamesPlay three or four games. Ask for a reason each time.Vote and say why.
8–17 mininput()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 minif, elif, elseType-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 minand, or, notType-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 minTicket machineShow the boilerplate and read the numbered steps. Let them press Check often.Follow the steps.
42–49 minGrade calculatorDo step 1 together, then let them finish.Finish the activity.
49–54 minQuiz showIf time is short, set it as homework.Try the challenge.
54–59 minQuizRead each question aloud. Vote, then check.Answer and read why.
59–60 minSet the after-class projectOpen 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

For a child’s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

We’ll use your details only to respond to this request.

Chat on WhatsApp
Esc

Try