Foundation project

Project: a study scorecard

Lesson 12 of 20 · 18 min · Module 4: Reliable little programs

Build a small report from a set of learner records. This project combines conditions, loops, lists, dictionaries, and functions.

Start this lesson →

Free. No installation: you write and run the code in your browser, and it is checked automatically.

By the end, you’ll be able to…

  • Translate a report specification into data operations
  • Guard an empty average
  • Return a consistent dictionary shape

The idea

Each record contains name and a numeric score. A passing score is at least 50. Reports should behave sensibly even when there are no records.

records = [
    {"name": "Alex", "score": 80},
    {"name": "Sam", "score": 40}
]

01Write the output contract first

The report has exactly three roles: a count, an average, and a list of names. Work out one example by hand before writing the function.

02Test different kinds of records

Try mixed pass/fail scores, a score exactly equal to 50, all passing scores, and an empty input. A correct normal case alone does not guarantee a correct function.

Your project brief

Define study_report(records) to return a dictionary with count (all records), average (all scores, or 0 when empty), and passed (names scoring at least 50, in input order).

What the checks look for

  • Reports count, average, and passing names
  • Handles the pass boundary
  • Handles an empty collection
  • Preserves input order
Try it in the editor →

Take this with you

Combine small operations around a clear contract, and make edge cases part of the design.

Learn Python Foundations for free

20 short lessons with real code and instant checks.

See the whole course →