Mike
0
Q:

how to use a function to find the average in python

# Example to find average of list
number_list = [45, 34, 10, 36, 12, 6, 80]
avg = sum(number_list)/len(number_list)
print("The average is ", round(avg,2))
5
# Using statistics package to find average
import statistics as st

my_list = [9, 3, 1, 5, 88, 22, 99]
print(st.mean(my_list))
3
 avreage_cost = cost
    avg = sum(avreage)/len(avreage) 
    print("The average amout you spent is ", round(avg,2))
0
import numpy

 avreage_1 = numpy.mean(avreage)# this finds the mean from the array "cost"
    print("words are printed here if needed",avreage_1) # this prints the mean that was found above
    
    
0

New to Communities?

Join the community