Python Find Average of List Example Tutorial

Published On: 01/12/2022 | Category: Python


Hi Guys,

This tutorial is focused on how to find average of list in python. you can understand a concept of python find average of list example. This tutorial will give you simple example of python list find average. we will help you to give example of python count average of list. you will do the following things for how to find the average value of a list in python.

In Python, there are numerous methods for calculating the average list value. I'll show you three examples of how to calculate the average of a list in Python.

  1. Sum of List divided by the length of List
  2. using statistics Module
  3. using NumPy library

So let's see bellow example:

Example 1: Sum of List divide by length of List

main.py
myList = [10, 5, 23, 25, 14, 80, 71]
  
# Find Average from List
avg = sum(myList)/len(myList)
  
print(round(avg,2))
Output
32.57

Example 2: using statistics Module

main.py
from statistics import mean
  
myList = [10, 5, 23, 25, 14, 80, 71]
  
# Find Average from List
avg = mean(myList)
  
print(round(avg,2))
Output
32.57

Example 3: using numpy library

main.py
from numpy import mean
  
myList = [10, 5, 23, 25, 14, 80, 71]
  
# Find Average from List
avg = mean(myList)
  
print(round(avg,2))
Output
32.57

It will help you....

Happy Pythonic Coding!