Finding the mean (average) of a list in Python can be done by using the statistics
module or manually calculating the sum and dividing by the length of the list. Here are two examples:
Example 1:
import statistics numbers = [1, 2, 3, 4, 5] mean = statistics.mean(numbers) print(f"The mean of the list is: {mean}")
Output:
The mean of the list is: 3
Example 2:
grades = [85, 90, 92, 88, 95] mean = sum(grades) / len(grades) print(f"The mean grade is: {mean}")
Output:
The mean grade is: 90.0