Answer to Question #224151 in Python for kaavya

Question #224151

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.


1
Expert's answer
2021-08-07T03:29:42-0400
#Python 3.9.5

def get_numbers():
    list = [int(x) for x in input('Enter sequence of numbers: ').split(' ')]
    return list

def get_awerage(list):
    awerage = sum(list)/len(list)
    return awerage

def main():
    list = get_numbers()
    print('Awerage from the list: ', round(get_awerage(list), 2))

if __name__ == "__main__":
    main()

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