Python program to Get the Arithmetic Mean of a List

def avg_list(first):
 last = len(first)
 sum = 0
 for i in first:
    sum += i
 return sum/last
x = input("Insert some integer values: ")
x = x.split()
for i in range(len(x)):
 x[i] = int(x[i])
average = avg_list(x)
print("The result of the average =",round(average,2))

 

 

 

Output:

Insert some integer values: 4578
The result of the average = 4578.0

 

Insert some integer values: 4 8 9 3
The result of the average = 6.0

 

Subscribe For Daily Updates