Python – Find Average of Numbers in List

Find average of numbers in list

To find the average of numbers in given list in Python, find the sum of the numbers using sum() builtin function and divide the sum with the number of elements in the list.

The syntax of the expression to find the average of numbers in the list x is

sum(x) / len(x)

Examples

1. Find average of items in list x

In the following program, we take a list x, and find the average of numbers in the list x.

Python Program

x = [4, 0, 5, 7, -1, 3]
result = sum(x) / len(x)
print(result)
Run Code Copy

Output

3.0

Summary

In this tutorial of Python Examples, we learned how to find the average of numbers in the given list using sum() and len() builtin functions, with the help of well detailed examples.

Code copied to clipboard successfully 👍