asked 18.9k views
5 votes
write a program to input the lines one at a time. you are to print each line of data followed by the highest mean for the week, the lowest mean and the mean of the means

asked
User Macron
by
8.3k points

1 Answer

3 votes

Answer:

Step-by-step explanation:

Here's a Python program that takes input lines one at a time, prints each line of data, and calculates the highest mean, lowest mean, and mean of the means:

```python

# initialize variables

highest_mean = float('-inf')

lowest_mean = float('inf')

total_mean = 0

count = 0

# input lines one at a time

while True:

try:

line = input()

except EOFError:

break

# print each line of data

print(line)

# calculate mean of current line

nums = [float(num) for num in line.split()]

mean = sum(nums) / len(nums)

# update highest and lowest means

highest_mean = max(highest_mean, mean)

lowest_mean = min(lowest_mean, mean)

# update total mean and count

total_mean += mean

count += 1

# calculate mean of the means

mean_of_means = total_mean / count

# print results

print('Highest mean:', highest_mean)

print('Lowest mean:', lowest_mean)

print('Mean of the means:', mean_of_means)

```

To use this program, simply run it in a Python environment and input the lines of data one at a time. The program will print each line of data, followed by the highest mean, lowest mean, and mean of the means.

No related questions found