Python Home Work Problem: Sum, Average, MaX and MIN

preview_player
Показать описание
# Python program that allows the user to enter exactly twenty floating-point values.
# The program then prints the sum, average (arithmetic mean), maximum, and minimum of the values entered.
Рекомендации по теме
Комментарии
Автор

hey man, please help me:

I need to find the min, max and avg on python 2.7 please

I have a text file called input.txt. the text file has the following information:
Min: 1, 2, 3, 4, 5, 6
Max: 1, 2, 3, 4, 5, 6
Avg: 1, 2, 3, 4, 5, 6

The program must get the information from input.txt and output the following in a text file called output.txt:

The min of [1, 2, 3, 4, 5, 6] is 1
The max of [1, 2, 3, 4, 5, 6] is 6
The avg of [1, 2, 3, 4, 5, 6] is 3.5

My code so far is:

in_file = open("input.txt", "r")
out_file = open("output.txt", "w")
Data = in_file.readline()
Numbers = data.split() # split the string so I can manipulate each element if need be

That's where I get stuck. I haven't put it in a loop yet because I want to first get the calculations correct.

I'm using python 2.7

zeedlomo