# mean() Function of statistics Module in Python (Example)

In this Python programming tutorial you’ll learn how to **apply the statistics.mean function**.

The post looks as follows:

Let’s start right away!

## Creation of Example Data

First, let’s create some example data.

my_list = [4, 3, 8, 7, 8, 4, 4, 1, 5] # Create example list print(my_list) # Print example list # [4, 3, 8, 7, 8, 4, 4, 1, 5] |

my_list = [4, 3, 8, 7, 8, 4, 4, 1, 5] # Create example list print(my_list) # Print example list # [4, 3, 8, 7, 8, 4, 4, 1, 5]

The previous output of the Python console shows the structure of our example data: We have constructed a list object containing nine integer values.

## Example: Apply mean() Function of statistics Module to List

The Python programming code below illustrates how to apply the mean function of the statistics module to get the average of a list of values.

If we want to use the functions of the statistics library, we also have to load statistics:

import statistics # Import statistics |

import statistics # Import statistics

In the next step, we can apply the mean function of the statistics module to return the arithmetic mean of our data:

print(statistics.mean(my_list)) # Apply statistics.mean function # 4.888888888888889 |

print(statistics.mean(my_list)) # Apply statistics.mean function # 4.888888888888889

As you can see, the mean of our data is 4.889.

## Video, Further Resources & Summary

Do you need further explanations on the Python code of this article? Then you might have a look at the following video on my YouTube channel. In the video, I show the Python programming codes of this tutorial:

*The YouTube video will be added soon.*

Besides the video, you may read the related posts that I have published on this website:

- Calculate Mean in Python
- Mean of Columns & Rows of pandas DataFrame
- Calculate Mean by Group in Python
- mean() Function of NumPy Library
- Replace NaN Values by Column Mean in Python
- Python Programming Examples

In this tutorial, I have illustrated how to **use the statistics.mean function** to compute and find the arithmetic mean in Python. If you have further questions, don’t hesitate to let me know in the comments.