python function to find average of list code example
Example 1: find average of list python
list = [15, 18, 2, 36, 12, 78, 5, 6, 9]
average_method_one = sum(list) / len(list)
average_method_two = sum(list) / float(len(list))
print(average_method_one)
print(average_method_two)
Example 2: make averages on 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]))