**Python’s List Object type** is quite useful for storing data while dealing with Scientific Computations where large amount of data need to be processed. Anyway, in this article => I’ll discuss **How to Calculate average of numbers in a Python List?**

Let’s see different Algorithmic approaches which can be implemented as Python Code calculating average of numbers in List. There are three algorithmic methods which can be used for this =>

- Using
**sum() Function**for calculating average of numbers in List - Using
**reduce() and lambda functions**for calculating average of numbers in List - Calculating average of numbers in a List using
**mean() function**

Let’s discuss each one of these approaches by one-by-one.

Table of Contents

## Approach 1 => Find Average of List in Python

Below are algorithmic steps which can be followed for calculating average of numbers in a List using **sum() function**.

- Define Python List
- Define a
**Python Function Average(a_list)**which divides sum of all elements in list with length of list using**sum(a_list)/len(a_list)**statement - Just call the
**function Average(a_list)**

```
# Python program to calculate the average of numbers in List
a_list = [15, 9, 55, 41, 35, 20, 62, 49] # Define Python List
def Average(a_list):
return sum(a_list) / len(a_list)
# Printing average of numbers in list rounded upto 2 digits
print("Average of the list => ", round(Average(a_list), 2))
```

**Output of Above Code**

`Average of the list => 49.78`

## Approach 2 => Calculating Average of List in Python

Below are algorithmic steps which can be followed for calculating average of numbers in a List using **reduce() and lambda functions**.

- Import
**reduce function**from**functools Python Module** - Define a Python List as
**a_list** - Define a
**Python Function Average(a_list)**which using**reduce() function and len(a_list)**calculates average of numbers in Python List.

```
# Python program to calculate average of a list Using reduce() and lambda
# importing reduce() function from functools module
from functools import reduce
a_list = [18, 38, 13, 675, 28] # Define Python List
def Average(a_list):
return reduce(lambda a, b: a + b, a_list) / len(a_list)
# Printing average of the list
print("Average of the list =>", round(Average(a_list), 2))
```

**Output of Above Code**

`Average of the list => 154.4`

## Approach 3 => Figuring Out Average of Numbers in Python List

Below are algorithmic steps which can be followed for calculating average of numbers in a List using **mean() function**.

- Import
**mean function**from Python’s Module statistics - Define a Python List as
**a_list** - Define a
**Python Function Average(a_list)**which takes in Python List and calculate its mean by passing list to**mean() Function** - Calling function
**Average(a_list)**passing in a list as parameter will return average of numbers in List

```
# Python program to get average of a list using mean() Function
# importing mean() function statistics Python Module
from statistics to import mean
# Defining a Python List
a_list = [72, 81, 98, 34, 17]
def Average(a_list):
return mean(a_list)
# Printing average of the list
print("Average of the list => ", round(Average(a_list), 2))
```

**Output of Above Code**

`Average of the list => 60.4`

## No Comments

Leave a comment Cancel