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.

`$\bar{x} = \frac{x_1 + x_2 … + x_{n}}{n}$`

The equation above is used to calculate mean. `x1`

, `x2`

, … `xn`

are observations from a dataset of `n`

observations.

#### Example

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

`$4 + 6 + 2 + 8 = 20$`

##### Step Two: Divide by the number of observations

The total is equal to 20, and the number of observations is equal to 4.

`$\frac{20}{4} = 5$`

The average of this dataset is equal to 5.

### Instructions

**1.**

In this exercise, you will use Python to find the average age of the first four authors in Le Monde’s top 100 books.

`$29, 49, 42, 43$`

Add the values together, and set `total`

equal to the answer.

**2.**

Divide `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.

# Sign up to start coding

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.