-
Notifications
You must be signed in to change notification settings - Fork 0
ДЗ к 5 уроку #3
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
Open
getblad
wants to merge
1
commit into
master
Choose a base branch
from
lesson5
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ДЗ к 5 уроку #3
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| with open('text1.txt', mode='w') as write_dt: | ||
| data = input() | ||
| while data != '': | ||
| write_dt.write(f'{data}\n') | ||
| data = input() | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| with open('text2.txt', 'r') as txt: | ||
| string = 1 | ||
| for line in txt: | ||
| print(f'количество слов в строке {string} - {len(line.split())}') | ||
| string += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| with open('text3.txt', 'r', encoding='UTF-8') as txt: | ||
| average = 0 | ||
| count = 0 | ||
| for line in txt: | ||
| try: | ||
| salary = int(line.split(' - ')[1]) | ||
| if salary < 20000: | ||
| print(line, end='') | ||
| average += salary | ||
| count += 1 | ||
| except ValueError: | ||
| print('В файле обнаружена ошибка ввода заработной платы!') | ||
| except IndexError: | ||
| break | ||
| print(f'Средняя заработанная плата {average/count:.2f}') | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| numbers = {'One': 'один', 'Two': 'два', 'Three': 'три', 'Four': 'четыре'} | ||
| with open('text4.txt', 'r', encoding='UTF-8') as txt1: | ||
| with open('text4_1.txt', 'w', encoding='UTF-8') as txt2: | ||
| for line in txt1: | ||
| x = line.split(" — ") | ||
| try: | ||
| txt2.write(f'{numbers[x[0]]} — {x[1]}') | ||
| except KeyError: | ||
| print('В исходном файле обнаружена ошибка соответствия!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from random import randint | ||
|
|
||
|
|
||
| with open('text5.txt', 'w', encoding='UTF-8') as txt: | ||
| for i in range(5): | ||
| txt.write(f'{str(randint(1, 100))} ') | ||
| with open('text5.txt', 'r', encoding='UTF-8') as txt: | ||
| print(sum(map(int, txt.readline().split()))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from itertools import cycle | ||
|
|
||
|
|
||
| dict = {} | ||
| with open('text6.txt', 'r', encoding='UTF-8') as txt: | ||
| for line in txt: | ||
| subject = ''.join(line.split()[:1])[:-1] | ||
| sum = 0 | ||
| for a, n in zip(line.split()[1:], cycle([3, 4, 5])): | ||
| if a == '—': | ||
| continue | ||
| sum += int(a[:-n]) | ||
| dict[subject] = sum | ||
| print(dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import json | ||
|
|
||
| dict_prof = {} | ||
| dict_aver = {} | ||
| with open('text7.txt', 'r', encoding='UTF-8') as txt: | ||
| count = 0 | ||
| suma = 0 | ||
| for line in txt: | ||
| name, ownership, income, costs = line.split() | ||
| profit = int(income) - int(costs) | ||
| dict_prof[name] = profit | ||
| suma += profit | ||
| count += 1 | ||
| dict_aver['average_profit'] = suma/count | ||
| lists = [dict_prof, dict_aver] | ||
| with open("text7.json", "w") as txt: | ||
| json.dump(lists, txt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| sf | ||
| 324 | ||
| shrt | ||
| 44444 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| fefef sfefsf | ||
| sdfsf jsdkfjsdf jsfkdf | ||
| sdfj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Иванов - 20000 | ||
| Петров - 10000 | ||
| Сидоров - 30000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| One — 1 | ||
| Two — 2 | ||
| Three — 3 | ||
| Four — 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| один — 1 | ||
| два — 2 | ||
| три — 3 | ||
| четыре — 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 58 64 37 84 66 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Информатика: 100(л) 50(пр) 20(лаб) | ||
| Физика: 30(л) — 10(лаб) | ||
| Физкультура: — 30(пр) — |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [{"firm_1": 5500, "firm_2": 9400, "firm_3": -10000}, {"average_profit": 1633.3333333333333}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| firm_1 ООО 10500 5000 | ||
| firm_2 ОАО 10000 600 | ||
| firm_3 ЗАО 20000 30000 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
хорошо