Answer to Question #228702 in Python for srikanth

Question #228702
Average of Given Numbers

You are given space-separated integers as input. Write a program to print the average of the given numbers.

Input

The first line of input contains space-separated integers.

Output

The output should be a float value rounded up to two decimal places.

Explanation

In the example, input is 

1, 0, 2, 5, 9, 8. The sum of all numbers present in the list is 25, and their average is 25/6.

So, the output should be 

4.17.

Sample Input 1
1 0 2 5 9 8
Sample Output 1
4.17
Sample Input 2
1 2 3 4 5
Sample Output 2
3.0

1
Expert's answer
2021-08-25T05:47:02-0400
n=int(input("Enter the number of elements to be inserted: "))


a= []
for i in range(0,n):
    elem=int(input("Enter element: "))
    a.append(elem)
avg=sum(a)/n
print("Average of elements in the list", round (avg, 2))

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
APPROVED BY CLIENTS