How to Calculate the Average of a List

The average (mean) of a list can be calculated by dividing the sum of the list elements by the number of elements.

Example: Calculating Average

# Calculating average of a list
numbers = [10, 20, 30, 40, 50]
average = sum(numbers) / len(numbers)
print(f"The average is {average}.")

Output

The average is 30.0.

Explanation: The sum of the numbers is divided by the number of elements to calculate the average.