Find average of list in Python

There are multiple ways to find the average of the list in Python.

Using sum() and len()

We can use sum() to find sum of list and then divide it with len() to find average of list in Python.

Here is the quick example of the same.

💻 Awesome Tech Resources:
  • Looking for ⚒️ tech jobs? Go to our job portal.
  • Looking for tech events? Go to tech events 🗓️ Calendar.️

Output:

Average of listOfIntegers: 3.0

Using reduce(), lambda and len()

We can use reduce() and lambda to find sum of list and then divide it with len() of list.

Output:

Average of listOfIntegers: 3.0

Using mean()

We can also directly use inbuilt function mean() from statistics module.

Output:

Average of listOfIntegers: 3

That’s all about find average of list in Python.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.