How to Find Average of List in Python?
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
myList = [10, 5, 23, 25, 14, 80, 71] # Find Average from List avg = sum(myList)/len(myList) print(round(avg,2))
Example 2: using statistics Module
from statistics import mean myList = [10, 5, 23, 25, 14, 80, 71] # Find Average from List avg = mean(myList) print(round(avg,2))
Example 3: using numpy library
from numpy import mean myList = [10, 5, 23, 25, 14, 80, 71] # Find Average from List avg = mean(myList) print(round(avg,2))
I hope it can help you...
We are Recommending you
- Python List Print All Elements Except Last Example
- How to Get Min Value from Python List?
- How to Convert List to Capitalize First Letter in Python?
- How to Get Max Value from Python List?
- How to Convert List to Uppercase in Python?
- Python Convert List into String with Commas Example
- How to Convert List to Lowercase in Python?
- How to Convert List into String in Python?
- Python Split String into List of Characters Example
- How to Convert String into List in Python?
- Python Remove Empty String from List Example
- Python Get Second Last Element of List Example