mean value in python code example

Example 1: average python

import numpy as np
values=[1,10,100]
print(np.mean(values))
values=[1,10,100,np.nan]
print(np.nanmean(values))

Example 2: python mean

# Probably the most convenient set of statistics functions are found
# in the Numpy package

# Basic syntax:
import numpy as np
np.mean(your_list) # Calculate mean
np.median()	# Calculate median
np.std()	# Calculate standard deviation
np.var()	# Calculate variance

Example 3: mean python code

>>> def my_mean(sample):
...     return sum(sample) / len(sample)
...

>>> my_mean([4, 8, 6, 5, 3, 2, 8, 9, 2, 5])
5.2