Answer to Question #316789 in Python for MEAN1

Question #316789

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


1
Expert's answer
2022-03-25T04:36:30-0400
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)))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS