python calculate mean of list code example
Example 1: average value of list elements in python
number_list = [45, 34, 10, 36, 12, 6, 80]
avg = sum(number_list)/len(number_list)
print("The average is ", round(avg,2))
Example 2: list mean python
def Average(lst):
return sum(lst) / len(lst)
lst = [15, 9, 55, 41, 35, 20, 62, 49]
average = Average(lst)
print("Average of the list =", round(average, 2))
Example 3: python average
import statistics as st
my_list = [9, 3, 1, 5, 88, 22, 99]
print(st.mean(my_list))
Example 4: python find average of list
numbers = [1,2,3,4,5,6,7,889,102390143]
def find_average(number_list):
total = 0
for number in number_list:
total += number
average = total / len(number_list)
print("Your average is:", average)
find_average(numbers)