def avrg(values): # where values is a list of all values
return sum(values)/len(values)
numbers = [3, 18, 2, 1, 70, 12, 36, 12, 78, 5, 6, 9]
import statistics
print(statistics.mean(numbers))
import numpy as np
values=[1,10,100]
print(np.mean(values))
values=[1,10,100,np.nan]
print(np.nanmean(values))
def mean(numbers):
numbers.sort()
q = len(numbers) // 2
if len(numbers) % 2 !=0:
return numbers[q]
elif len(V) % 2 == 0:
return (numbers[q - 1] + numbers[q]) / 2
History = 97
English = 92
Math = 85
Science = 86
Total = History + English + Math + Science
Average = Total/4
print('Total of grades:', Average)
def cal_average(num):
sum_num = 0
for t in num:
sum_num = sum_num + t
avg = sum_num / len(num)
return avg
print("The average is", cal_average([18,25,3,41,5]))