WEB PRACTICE W011Age eligibility
Determine whether someone aged 14 is eligible for a 13+ coding workshop.
Reveal a hint
Use >= for an inclusive lower bound.
Reveal example code (after trying it yourself)
age = 14
if age >= 13:
print("Eligible")
else:
print("Not eligible")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W012Even or odd
Decide whether the number 37 is even or odd.
Reveal a hint
An even integer has a remainder of zero on division by 2.
Reveal example code (after trying it yourself)
number = 37
if number % 2 == 0:
print("Even")
else:
print("Odd")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W013Temperature bands
Classify a temperature of 17°C as cold, mild or hot.
Reveal a hint
Put the lowest threshold in the first branch.
Reveal example code (after trying it yourself)
temp = 17
if temp < 10:
print("Cold")
elif temp < 25:
print("Mild")
else:
print("Hot")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W014Pass or retry
Display Pass for a quiz score of 68 when the pass mark is 50.
Reveal a hint
Use >= so exactly 50 also passes.
Reveal example code (after trying it yourself)
score = 68
print("Pass" if score >= 50 else "Try again")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W015Discount threshold
Apply a 10% discount to a £60 order when spending reaches £50.
Reveal a hint
Calculate the adjusted price in only one branch.
Reveal example code (after trying it yourself)
total = 60.0
if total >= 50:
total *= 0.90
print(f"Pay £{total:.2f}")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W016Username length
Check whether a username is at least six characters long.
Reveal a hint
Use len(username).
Reveal example code (after trying it yourself)
username = "coder72"
if len(username) >= 6:
print("Length accepted")
else:
print("Too short")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W017Safety equipment
A workshop requires a helmet and safety glasses. Check both conditions.
Reveal a hint
The and operator requires both values to be True.
Reveal example code (after trying it yourself)
helmet = True
glasses = False
if helmet and glasses:
print("Ready")
else:
print("Check equipment")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W018Ticket age band
Choose a child, teen or adult ticket for someone aged 16.
Reveal a hint
Make the conditions mutually exclusive.
Reveal example code (after trying it yourself)
age = 16
if age < 12:
ticket = "child"
elif age < 18:
ticket = "teen"
else:
ticket = "adult"
print(ticket)
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W019Leap year rules
Check whether 2024 is a leap year using the full divisible-by-4/100/400 rule.
Reveal a hint
Century years must be divisible by 400.
Reveal example code (after trying it yourself)
year = 2024
leap = (year % 4 == 0 and year % 100 != 0) or year % 400 == 0
print("Leap year" if leap else "Not leap year")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W020Safe range
Decide whether a sensor reading of 27 is inside the inclusive safe range 18–30.
Reveal a hint
Use a chained comparison.
Reveal example code (after trying it yourself)
reading = 27
if 18 <= reading <= 30:
print("Safe range")
else:
print("Outside range")
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.