question archive 6

6

Subject:Computer SciencePrice:3.87 Bought7

6.12 LAB: Varied amount of input data

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

247772.1580548

LABACTIVITY

6.12.1: LAB: Varied amount of input data

0 / 10

1

''' Type your code here. '''

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Answer:

 

# take input from the screen
numbers = input()

# split the number
numbers_list = numbers.split()

# convert the numbers into integer
numbers_list = [int(x) for x in numbers_list]


total = 0
max_number = -9999999

# calculate the total and max integer
for num in numbers_list:
    total = total + num
    if num > max_number:
        max_number = num


average = total / len(numbers_list)

# display the results
print(str(f'{float(average):g}'), max_number)

Related Questions