Answer to Question #243493 in Python for balu

Question #243493
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

input should be single line
1
Expert's answer
2021-09-30T00:58:26-0400
n=int(input("Enter the number of elements to be inserted: "))


a = [int(i) for i in input().split()][:n]
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
New on Blog
APPROVED BY CLIENTS