โ ๐ Python World
๐ Grade Machine
You can practise without a player, but pick a player to score points!
๐ The mission
Today you unlock
If statements choose a path
An if statement checks a condition and chooses which answer to return. Order matters: check the special cases first.
๐ก Hint ladder
- if / elif / else, checking the biggest scores first.
- if score >= 90: return "A"
๐งช Coach checks
- โฏ 95 is an A
- โฏ 90 exactly is A
- โฏ 85 is a B
- โฏ 70 exactly is C
- โฏ 69 tries again
Live coach
Getting ready
โโโ
๐ฌ if / elif / else โ biggest scores checked first, else catches the rest.
def medal(place):
if place == 1:
return "gold"
elif place == 2:
return "silver"
elif place == 3:
return "bronze"
else:
return "keep trying"
print(medal(1)) # gold
print(medal(5)) # keep trying
๐ It printed:
Nice โ you saw it work!
๐ Output
๐งฉ Gaps filled! Ready to write it all yourself?