The mean, often referred to as the average, is a way to measure the center of a dataset.
The average of a set is calculated using a two-step process:
- Add all of the observations in your dataset.
- Divide the total sum from step one by the number of points in your dataset.
The equation above is used to calculate mean.
xn are observations from a dataset of
Imagine that we wanted to calculate average of a dataset with the following four observations:
data = [4, 6, 2, 8]
Step One: Calculate the total
Step Two: Divide by the number of observations
The total is equal to 20, and the number of observations is equal to 4.
The average of this dataset is equal to 5.
In this exercise, you will use Python to find the average age of the first four authors in Le Monde’s top 100 books.
Add the values together, and set
total equal to the answer.
total by the number of values in the dataset, and set
mean_value to the answer.
Take a look at the result in the terminal. Keep that number in your head as you progress through the lesson.