▶ Sign up free for the video, slides & prompts
The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.
Checking…
Mini project: student marks report
Totals, grades and toppers from a class's marks.
🎬 Video version coming soon — read it now
Let's combine lists, dictionaries, loops and string cleaning into a report a class teacher could really use.
The data
Each line is a name and three marks, typed carelessly.
Step 1: clean into a list of dictionaries
[p.strip() for p in ...] is a list comprehension: a short way to build a list. It's the same as a loop with append.
Step 2: totals, averages and grades
def grade is a function, a named, reusable piece of code. That's the whole of the next course. all(...) is True only if every mark is 35 or more.
Step 3: print the report
Step 4: class summary
Challenges
- Find the topper in each subject.
- Add a fourth subject and make sure nothing else needs to change.
- Show students who failed exactly one subject: they can clear it in supplementary exams.
- Ask AI for 30 more messy rows and check your code still works.
What you learned in this course
- Lists, tuples, sets and dictionaries, and when to use each
- Looping, filtering, sorting and grouping data
- Lists of dictionaries: the shape of real data
- Cleaning messy text, and generating safe practice data with AI
Next course: Functions & Clean Code. You'll break programs like this into small reusable pieces, handle errors and debug calmly.
In one line
You turned messy text into a ranked report with grades and a class summary, which is real data work.
Share with a friend