get the mean value of a python list code example
Example 1: python average
import statistics as st
my_list = [9, 3, 1, 5, 88, 22, 99]
print(st.mean(my_list))
Example 2: how to use a function to find the average in python
avreage_cost = cost
avg = sum(avreage)/len(avreage)
print("The average amout you spent is ", round(avg,2))
Example 3: calcutalte average python
def averageOfList(num):
sumOfNumbers = 0
for t in num:
sumOfNumbers = sumOfNumbers + t
avg = sumOfNumbers / len(num)
return avg
print("The average of List is", averageOfList([19, 21, 46, 11, 18]))