Lesson 3 of 7
Total and average
sum(list) adds everything, len(list) counts the items: the average is sum / len.
These two functions save you from writing loops for the most common calculations.
values = [4, 6] print(sum(values)) # 10 print(sum(values) / len(values)) # 5.0
🎯 Your goal
With values = [12, 8, 10]: compute total (the sum) and avg (the average), then print both.
PRO lesson
This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.
Discover PRO →