Compare commits
2 Commits
74024713b3
...
e5e17f9b2e
Author | SHA1 | Date | |
---|---|---|---|
|
e5e17f9b2e | ||
|
cd60369b65 |
@ -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)
|
||||||
|
25
practica/stepik/stepik_tasks/test.py
Normal file
25
practica/stepik/stepik_tasks/test.py
Normal 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)))]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user