Average of a list
Write a Python program to calculate the average of a list.
[3, 5, 7, 2, 6, 12, 3]
5.428571428571429 5.43
Approach
sum / len.
Solution
numbers = [3, 5, 7, 2, 6, 12, 3]avg = sum(numbers) / len(numbers)print(avg, round(avg, 2))5.428571428571429 5.43
Learn the concept
New to this topic? Read the lesson, then come back.