Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

 Is there a built-in or standard library method in Python to calculate the arithmetic mean (one type of average) of a list of numbers?

1 Answer

0 votes
by (106k points)

You can use the below-mentioned code for calculating arithmetic mean in Python:-

def mean(numbers): 

return float(sum(numbers)) / max(len(numbers), 1) 

>>> mean([1,2,3,4]) 

2.5 

>>> mean([]) 

0.0

To know more about this you can have a look at the following video tutorial:-

Browse Categories

...