Compare commits

...

2 Commits

Author SHA1 Message Date
Есения Очеретяная
e5e17f9b2e add new task 2024-03-07 17:32:13 +03:00
Есения Очеретяная
cd60369b65 add new part of task 2024-03-07 15:38:18 +03:00
2 changed files with 50 additions and 1 deletions

View File

@ -52,4 +52,28 @@ with open ('text.txt', 'r') as text:
o = '' o = ''
t+=b t+=b
with open ('test.txt', 'w') as text: with open ('test.txt', 'w') as text:
text.write(t) text.write(t)
# подсчет одинаковых слов и вывод самого большого кол-ва раз
list = {}
ind = 0
len = 0
full_list = []
num = 0
with open ('text.txt', 'r') as text:
lines = [line.split() for line in text]
for parts in lines:
full_list += parts
for words in full_list:
len +=1
if ind != (len+1):
if words in full_list:
n = full_list.count(words)
list[words] = (n)
ind+=1
it = 0
for key, items in list.items():
if items > it:
it = items
it_key = key
print (it_key, it)

View File

@ -0,0 +1,25 @@
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)))]))