Lab · School of Computer Science & Technology

Lab 4 — Capstone: A Tiny Gradebook

⏱️ ~6 minutes (don't worry about finishing) · Use Python. Solutions in solutions.html.

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

  1. Reuse your grade(score) function from Lab 3.

  2. Loop over students. For each one, print their name, score, and letter grade:

    Ada    | 92 | A
    Linus  | 78 | C
    Grace  | 85 | B
    Alan   | 64 | F
  3. Compute and print the class average score. (Hint: sum the scores in a loop, divide by how many there are — or use sum(...) and len(...).)

  4. Print how many students passed (score ≥ 70).

Stretch (optional)

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.

← Lab 3Solutions →