mean
given a list of integers,write a program to print the mean.
mean - the average value of all the numbers.
input
the input will be a single line containing space-separated by integers.
output
the first line of output should contain the mean, round off the value to 2 decimal places.
mean should always be a float value.
see sample input/output for the output format.
explanation
for example, if the given list of integers are
2 4 5 6 7 8 2 4 5 2 3 8
the average of all the numbers is 4.67.
as the length of the list is an even number,
so the output should be
Mean: 4.67
for example, if the given list of integers are
2 6 3 1 8 12 2 9 10 3 4
the average of all the numbers is 5.45.
as the length of the list is an even number,
so the output should be
Mean: 5.45
sample input 1
2 4 5 6 7 8 2 4 5 2 3 8
sample output 1
mean: 4.67
sample input 2
2 6 3 1 8 12 2 9 10 3 4
sample output 2
mean: 5.45
a = input("Enter list of integers: ").split()
avg = 0.0
for i in range(len(a)):
a[i] = int(a[i])
avg = avg + a[i]
print('Mean: %.2f' % (avg/len(a)))
Comments
Leave a comment