Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

mean of a list python

l = [15, 18, 2, 36, 12, 78, 5, 6, 9]

# By using the built-in statistics library
import statistics
statistics.mean(l)  # 20.11111111111111

# By defining a custom function
def average(my_list):
  return sum(my_list) / len(my_list)
average(l) # 20.11111111111111
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #list #python
ADD COMMENT
Topic
Name
2+5 =