In [ ]:
#Write a function that takes in a list of numbers and outputs the mean of the numbers
#using the formula for mean.
#Do this without any built-in functions like sum(), len(), and, of course, mean()
In [58]:
def mean(a_list):
list_sum = 0
list_count = 0
for i in a_list:
list_sum += i
list_count += 1
return list_sum / list_count
In [60]:
list1 = [15, 34, 8, 19, 5]
mean(list1)
Out[60]:
In [62]:
import numpy #just to check
numpy.mean(list1)
Out[62]: