Python checkpoint: the basics
Builds on lessons 1 to 6. Start at lesson 1
Learn
On your own now
Four problems that use everything in Foundations: variables, arithmetic, strings, input, conversion and if. No starter code to lean on and no hints until you have checked once. Each problem is checked against several inputs, so a program that only works for the first one will not pass.
If one of them beats you, that is useful information: the result tells you which lesson to go back to.
Checkpoint
Seconds to a track length
Read a number of seconds and print it as minutes and seconds, the way a music app shows a track length: 207 becomes 3:27, 185 becomes 3:05. The seconds always have two digits.
Milestones
- 207 seconds
- 185 seconds
- Under a minute
- Exactly ten minutes
On your own: hints appear after your first check, a solution after 3 checks or if you give up.
Your program reads the Input box under the editor. Check also tries 3 other inputs.
Checkpoint
Check a new username
Read a username. Ignore spaces at either end. Then print the first message that applies:
No spaces allowedif there is a space inside itToo shortif it has fewer than 3 charactersToo longif it has more than 12- otherwise
OK:followed by the name in lower case
Milestones
- Spaces at the ends
- Space inside
- Two letters
- Seventeen letters
On your own: hints appear after your first check, a solution after 3 checks or if you give up.
Your program reads the Input box under the editor. Check also tries 3 other inputs.
CheckpointPredict the output
Trace the remainder
Type exactly what this prints.
x = 7
y = x // 2
x = x % 2
if x == 1 and y > 2:
print("odd", y)
else:
print("even", y)
print(f"{x}{y}")
CheckpointFix the bug
Free delivery never applies
Orders of over 50 pounds get free delivery. The program crashes before it prints anything. Fix it.
Milestones
- Over 50
- Under 50
- Exactly 50
On your own: hints appear after your first check, a solution after 3 checks or if you give up.
Your program reads the Input box under the editor. Check also tries 2 other inputs.
total = input()
if total > 50:
print("Free delivery")
else:
print("Delivery: 4.99")
Cleared
Go back to
You can now