-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson_5 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Lesson_5 #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
| 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') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
| 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)}') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
| 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]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
| 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() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
| 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}) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
| 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}') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Один - 1 | ||
| Два - 2 | ||
| Три - 3 | ||
| Четыре - 4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| line 1 | ||
| line 2 | ||
| zdarova kak dela | ||
| line 3 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 65 65 789 45 13 5 |
| 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} |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| One - 1 | ||
| Two - 2 | ||
| Three - 3 | ||
| Four - 4 |
| 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(лаб) |
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
выполнено