ItSolutionStuff.com

How to Find Average of List in Python?

By Hardik Savani • October 30, 2023
Python

Hi,

If you need to see an example of how to find average of list in python. We will look at examples of python list find average. I would like to show you python count average of list. you can understand the concept of how to find the average value of a list in python.

There are many ways to find an average list value in python. I will give you the following three examples to calculate an average of a list in python.

1. Sum of List divided by the length of List

2. using statistics Module

3. using NumPy library

Let's see one be one example.

You can use these examples with python3 (Python 3) version.

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

I hope it can help you...

Tags: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Python List Print All Elements Except Last Example

Read Now →

How to Get Min Value from Python List?

Read Now →

How to Convert List to Capitalize First Letter in Python?

Read Now →

How to Get Max Value from Python List?

Read Now →

How to Convert List to Uppercase in Python?

Read Now →

Python Convert List into String with Commas Example

Read Now →

How to Convert List to Lowercase in Python?

Read Now →

How to Convert List into String in Python?

Read Now →

Python Split String into List of Characters Example

Read Now →

How to Convert String into List in Python?

Read Now →

Python Remove Empty String from List Example

Read Now →

Python Get Second Last Element of List Example

Read Now →