Selection, conditions, IF/ELSE IF/ELSE, nested IF and SWITCH/CASE — with key meanings, a flowchart diagram, three hands-on challenges, a timed 25-question quiz with shuffled answers, a keyword matching game, a true/false speed round, and help for Task 2 at the bottom.
The important terms from this lesson, grouped by topic.
True or False — e.g. age >= 18.== != > < >= <= — used to build a condition.= assigns a value to a variable; == compares two values for equality.True.False.False.The diamond is the decision symbol — one way in, two ways out. Here's selection in action.
Decision symbol = diamond (one way in, two ways out)
↓ both paths lead on to
Drag each symbol name (or click one, then click a definition) onto what it represents.
Match each flowchart symbol below to what it represents.
Shows the start or end of the algorithm.
Shows an input or output step.
Shows a decision — one way in, two ways out.
Shows a process or calculation step.
Shows the direction the flow moves in, connecting the symbols together.
Trace through each piece of code and work out exactly what it will print, then pick your answer.
This program has four errors in it. Work out the correct version of each highlighted line.
temp = int(input("Enter temperature: "))
if temp = 30
print("Hot day")
else
print("Not hot")
Selection, conditions, IF/ELSE IF/ELSE, nested IF, SWITCH/CASE — and a few code-tracing questions. A timer starts as soon as you press Start, and the answer options are shuffled into a new order every question.
A timed matching game — match each keyword to its correct meaning. The clock starts on your first move, and the terms shuffle into a new order every time you play.
Drag each keyword (or click one, then click a meaning) onto the definition it matches.
15 rapid-fire statements about this lesson. You've got 10 seconds per statement — answer before the bar runs out!
Stuck on Task 2? Expand a hint below — the example code is there to check your work against once you've had a proper go yourself, not to copy and paste (the code can't be selected or copied).
Work out what this program prints when score is 85, then 60, then 30 — then check your answers against the example.
Tips
then and endif — real Python doesn't use then, and uses a colon plus indentation instead of endif.score = int(input("Enter score: "))
if score >= 80:
print("Excellent")
elif score >= 50:
print("Pass")
else:
print("Try again")
The buggy version in your task has four errors — a wrong comparison operator, two missing colons, and one missing indent. Here's the corrected version to check against.
Tips
temp = 30 only assigns a value — you need temp == 30 to compare it.if and else line needs a colon : at the end.else must be indented so Python knows it belongs to that block.temp = int(input("Enter temperature: "))
if temp == 30:
print("Hot day")
else:
print("Not hot")
Write a program using a nested IF that charges £5 for under-12s, £7 for students, and £10 for everyone else.
Tips
input() always returns a string, so cast the age to int() before comparing it with <.age = int(input("How old are you? "))
if age < 12:
print("Price: £5")
else:
student = input("Are you a student? (yes/no) ")
if student == "yes":
print("Price: £7")
else:
print("Price: £10")