Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and outputs the average and max. Ex: If the input is: 15 20 0 5 the output is: 10 20 Note: For output, round the average to the nearest integer.

Respuesta :

Answer:

txt = input("Enter numbers: ")

numbers = txt.split(" ")

total = 0

max = 0

for i in numbers:

     total = total + int(i)

     if(int(i)>max):

           max = int(i)

print(round(total/len(numbers)))

print(max)

Explanation:

This solution is implemented using Python programming language

This prompts user for input

txt = input("Enter numbers: ")

This splits user input into list

numbers = txt.split(" ")

The next two line initialize total and max to 0, respectively

total = 0

max = 0

This iterates through the list

for i in numbers:

This sum up the items in the list (i.e. user inputs)

     total = total + int(i)

This checks for the maximum

     if(int(i)>max):

           max = int(i)

This calculates and prints the average

print(round(total/len(numbers)))

This prints the max

print(max)

Answer:

txt = input()

numbers = txt.split(" ")

total = 0

max = 0

for i in numbers:

    total = total + int(i)

    if(int(i)>max):

          max = int(i)

print(round(total/len(numbers)), '', end="")

print(max)

Explanation:

I just added to the end so that the Max of 10 20 is on the same line with space

ACCESS MORE