list_temp = []
with open('file_name.txt', 'r') as temp:
for i in temp:
list_temp.append(i)
minTemp = min(list_temp)
maxTemp = max(list_temp)
print(f"Минимальная температура: {minTemp}\nМаксимальная температура: {maxTemp}")
=== Python 3.8.3 ===
import statistics
import re
def TakeFromFile(fname, SingleDataPackCapacity):
with open(fname, 'r', encoding='utf-8') as input_:
data = input_.read()
data = re.sub(r' +', ' ', re.sub(r'\n', ' ', data)).split(' ')
LastTakeIndex = 0
for TakeIndex in range(SingleDataPackCapacity, len(data)+SingleDataPackCapacity, SingleDataPackCapacity):
yield data[LastTakeIndex:TakeIndex]
LastTakeIndex = TakeIndex
for number, WeekData in enumerate(TakeFromFile('input.txt', 7)):
tmp = list(map(int, WeekData))
print(
f'Week: {number+1}\nMax temp: {max(tmp)}\nMin temp: {min(tmp)}\nAverage temp: {statistics.mean(tmp)}\n')
list_temp = []
with open('file_name.txt', 'r') as temp:
for i in temp:
list_temp.append(i)
minTemp = min(list_temp)
maxTemp = max(list_temp)
print(f"Минимальная температура: {minTemp}\nМаксимальная температура: {maxTemp}")
=== Python 3.8.3 ===
import statistics
import re
def TakeFromFile(fname, SingleDataPackCapacity):
with open(fname, 'r', encoding='utf-8') as input_:
data = input_.read()
data = re.sub(r' +', ' ', re.sub(r'\n', ' ', data)).split(' ')
LastTakeIndex = 0
for TakeIndex in range(SingleDataPackCapacity, len(data)+SingleDataPackCapacity, SingleDataPackCapacity):
yield data[LastTakeIndex:TakeIndex]
LastTakeIndex = TakeIndex
for number, WeekData in enumerate(TakeFromFile('input.txt', 7)):
tmp = list(map(int, WeekData))
print(
f'Week: {number+1}\nMax temp: {max(tmp)}\nMin temp: {min(tmp)}\nAverage temp: {statistics.mean(tmp)}\n')