Lesson 5 of 6
Aggregate into a report
A pipeline's output is often a small summary dictionary: count, average, maximum.
round(x, 2) stabilises floating-point averages — essential for reproducible reports.
stats = {
"count": len(scores),
"average": round(sum(scores) / len(scores), 2),
"top": max(scores),
}🎯 Exercise
From scores = [40, 80, 120, 60], build the stats dictionary with "count" (the number), "average" (the mean rounded to 2 decimals) and "top" (the maximum). Print stats["average"].
PRO lesson
This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.
Discover PRO →