What you'll build
Ask the user for a score out of 100 and print the grade they earned. The straightforward way to practice if, elif, and else on a single number.
Requirements
The must-do parts. If any are missing, we'll ask you to take another pass.
- Ask the user for a score and convert the answer to a number with
float(), so half-marks like 64.5 work. - Use
if,elif, andelseto decide the grade: 70 or above is *Distinction*, 50 to 69 is *Pass*, below 50 is *Fail*. - Print the grade as a single clear line.
- Use
>=(not>or==) so the cutoffs land where you want them.
Bonus, if you're feeling brave
- Add a fourth tier — *Merit* — between Pass and Distinction. Pick the cutoff yourself and keep it consistent.
- If the score is outside 0 to 100, print a friendly message and stop without crashing.
Examples
What your program should look like when it runs. Lines starting with $ are typed by you; the rest is your program.
Example cell runs
Score (0 to 100): 72
Distinction.
Score (0 to 100): 55
Pass.
Score (0 to 100): 30
Fail.Where to start
Copy this scaffold into a new file. You don't have to use it — it's just a friendly nudge.
# Score-to-grade decoder
score_text = input("Score (0 to 100): ")
score = float(score_text)
# TODO: use if / elif / else to print the gradeHow we'll grade it
Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.
| Check | What we look for | Pt |
|---|---|---|
| It runs | Starts cleanly, asks the question, prints a grade without errors. | 1 |
| All branches reachable | Distinction, Pass, and Fail each appear for the right scores. Try 30, 60, and 85. | 1 |
| Boundary correct | A score of exactly 50 prints Pass. A score of exactly 70 prints Distinction. | 1 |
| Readable output | The grade is on its own line, in plain English, no debug noise. | 1 |