Codzy

Project 6: a school report

Last project: compute a class's results like real school software. Each subject has a weight: the weighted average is the sum of "grade × weight" divided by the sum of the weights. A subject weighted 4 counts twice as much as one weighted 2.

We split the problem into small testable functions (weighted_average, mention), then put them together: ranking with sorted(..., reverse=True), positions with enumerate, column formatting, class average. Building a program brick by brick like this is how every professional project is made.

students = {"Lina": [15, 12, 18], "Omar": [9, 11, 8]}
for name, grades in students.items():
    average = sum(grades) / len(grades)
    print(f"{name:<6} {average:5.2f}")

Start the lesson