Lab · School of Computer Science & Technology
Lab 4 — Capstone: A Tiny Gradebook
Goal
Combine everything from today — collections, a loop, a function, conditionals, and types — into one small but real program. This is what "data work" actually looks like in miniature.
The data
students = [
{"name": "Ada", "score": 92},
{"name": "Linus", "score": 78},
{"name": "Grace", "score": 85},
{"name": "Alan", "score": 64},
]Tasks
Reuse your
grade(score)function from Lab 3.Loop over
students. For each one, print their name, score, and letter grade:Ada | 92 | A Linus | 78 | C Grace | 85 | B Alan | 64 | FCompute and print the class average score. (Hint: sum the scores in a loop, divide by how many there are — or use
sum(...)andlen(...).)Print how many students passed (score ≥ 70).
Stretch (optional)
- Find and print the top student (highest score).
- Print the average as a clean number with one decimal:
f"{avg:.1f}".
What you're practicing
This is the whole workshop in one program: a list of
dicts (a dataset!), a loop, a
function, conditionals,
type-aware math, and string
formatting. Swap students for a real CSV and
you've written your first data pipeline.