Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lesson_5/5-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
with open('File5_1.txt', 'w', encoding='utf-8') as perf:
while True:
line = input('введите текст, для окончания ввода оставте пустую строку: ')
if not line:
break
print(line, file=perf)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

4 changes: 4 additions & 0 deletions lesson_5/5-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
with open('File5_1.txt', 'r', encoding='utf-8') as perf:
res = [f'{line}. {count.strip()} - {len(count.split())} слова'
for line, count in enumerate(perf, 1)]
print(*res, f'Всего строк - {len(res)}.', sep='\n')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

9 changes: 9 additions & 0 deletions lesson_5/5-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
with open('text_3.txt', 'r', encoding='utf-8') as perf:
creeps = {}
for line in perf:
creeps[line.split()[0]] = float(line.split()[1])
print('менее 20к получают:')
for name, creep in creeps.items():
if creep < 20000:
print(name)
print(f'средняя з\п равна {sum(creeps.values()) / len(creeps)}')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

5 changes: 5 additions & 0 deletions lesson_5/5-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rus = {'One': 'Один', 'Two': 'Два', 'Three': 'Три', 'Four': 'Четыре'}

with open('File4_ru.txt', 'w', encoding='utf-8') as new_perf:
with open('text_4.txt', encoding='utf-8') as perf:
new_perf.writelines([line.replace(line.split()[0], rus.get(line.split()[0])) for line in perf])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

15 changes: 15 additions & 0 deletions lesson_5/5-5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def summary():
try:
with open('file5_5.txt', 'w+') as perf:
line = input('Введите цифры через пробел \n')
perf.writelines(line)
my_numbers = line.split()

print(sum(map(int, my_numbers)))
except IOError:
print('Ошибка в файле')
except ValueError:
print('Некорректные данные!')


summary()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

2 changes: 2 additions & 0 deletions lesson_5/5-6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
with open('text_6.txt', 'r', encoding='utf-8') as perf:
print({string.split(':')[0]: sum([int(s[:s.index('(')]) for s in string.split() if '(' in s]) for string in perf})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

28 changes: 28 additions & 0 deletions lesson_5/5-7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import json
profit = {}
pr = {}
prof = 0
prof_aver = 0
i = 0
with open('text_7.txt', 'r') as file:
for line in file:
name, firm, earning, damage = line.split()
profit[name] = int(earning) - int(damage)
if profit.setdefault(name) >= 0:
prof = prof + profit.setdefault(name)
i += 1
if i != 0:
prof_aver = prof / i
print(f'Прибыль средняя - {prof_aver:.2f}')
else:
print(f'Прибыль средняя - отсутсвует. Все работают в убыток')
pr = {'средняя прибыль': round(prof_aver)}
profit.update(pr)
print(f'Прибыль каждой компании - {profit}')

with open('file_7.json', 'w') as write_js:
json.dump(profit, write_js)

js_str = json.dumps(profit)
print(f'Создан файл с расширением json со следующим содержимым: \n '
f' {js_str}')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выполнено

4 changes: 4 additions & 0 deletions lesson_5/File4_ru.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Один - 1
Два - 2
Три - 3
Четыре - 4
4 changes: 4 additions & 0 deletions lesson_5/File5_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
line 1
line 2
zdarova kak dela
line 3
1 change: 1 addition & 0 deletions lesson_5/file5_5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
65 65 789 45 13 5
1 change: 1 addition & 0 deletions lesson_5/file_7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Brooms": 2000000, "Tandoor": -635000, "Honey-cake": 4795000, "Matrioshka": 4259000, "\u0421\u043a\u0430\u0437\u043a\u0430": 5500000, "\u0441\u0440\u0435\u0434\u043d\u044f\u044f \u043f\u0440\u0438\u0431\u044b\u043b\u044c": 4138500}
10 changes: 10 additions & 0 deletions lesson_5/text_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Иванов 10000.0
Петров 15000.0
Сидоров 25000.1
Иванова 15000.7
Петрова 19000.9
Сидорова 26000.1
Октябрьский 30000.5
Петровский 26000.4
Знаменский 12000.0
Корецкий 31000.9
4 changes: 4 additions & 0 deletions lesson_5/text_4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
One - 1
Two - 2
Three - 3
Four - 4
7 changes: 7 additions & 0 deletions lesson_5/text_6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Fizra: - 30(пр) -
Math: 10(л) 50(пр) -
History: 50(л) - -
Physics: 70(л) 20(пр) 18(лаб)
Informatics: 40(л) 12(пр) 20(лаб)
Literature: 10(л) - 8(лаб)
Russian: - - 90(лаб)
5 changes: 5 additions & 0 deletions lesson_5/text_7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Brooms ПАО 2500000 500000
Tandoor АО 1245000 1880000
Honey-cake ЗАО 5250000 455000
Matrioshka OOO 4770000 511000
Сказка ИП 10500000 5000000