26 lines
852 B
Python
26 lines
852 B
Python
def find_average(x):
|
|
return sum(x) / len(x)
|
|
|
|
med = 0
|
|
math = [] #математика
|
|
ph = [] #физика
|
|
ru = [] # русский
|
|
with open ('text.txt', 'r', encoding='utf-8') as f, open ('test.txt', 'w', encoding='utf-8') as f1:
|
|
lines = [line.split() for line in f]
|
|
li = 0 #кол-во строк
|
|
for i in lines:
|
|
for parts in i:
|
|
li+=1 #кол-во строк
|
|
y = parts.split(';') #
|
|
med = [int(y[1]),int(y[2]),int(y[3])] # среднее арифметическое каждого ученика
|
|
a = [int(item) for item in med]
|
|
f1.write(str(find_average(a)) + '\n')
|
|
math += [int(y[1])]
|
|
ph += [int(y[2])]
|
|
ru += [int(y[3])]
|
|
f1.write(' '.join([(str(find_average(math))), (str(find_average(ph))),(str(find_average(ru)))]))
|
|
|
|
|
|
|
|
|