wk02.p4Practice exerciseWeek 02 · Decisions and structureOpen · due in week 2

Score-to-grade decoder

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.

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.

  1. Ask the user for a score and convert the answer to a number with float(), so half-marks like 64.5 work.
  2. Use if, elif, and else to decide the grade: 70 or above is *Distinction*, 50 to 69 is *Pass*, below 50 is *Fail*.
  3. Print the grade as a single clear line.
  4. 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 grade

How we'll grade it

Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.

CheckWhat we look forPt
It runsStarts cleanly, asks the question, prints a grade without errors.1
All branches reachableDistinction, Pass, and Fail each appear for the right scores. Try 30, 60, and 85.1
Boundary correctA score of exactly 50 prints Pass. A score of exactly 70 prints Distinction.1
Readable outputThe grade is on its own line, in plain English, no debug noise.1
Ready?
Hand it in
You can submit a draft and revise later if you're not done.
Begin submission →