-
Notifications
You must be signed in to change notification settings - Fork 0
ДЗ 5.1 #111
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
Dimaly123
wants to merge
12
commits into
main
Choose a base branch
from
Lyagin
base: main
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.1 #111
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c112288
ДЗ 5.1
Dimaly123 b6135c9
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_M…
Dimaly123 01e5353
ДЗ 5.1 Edit1 + 5.2
Dimaly123 5a1e9f8
ДЗ 5.1 Edit2 + 5.2 Edit1
Dimaly123 6e4b9a8
ДЗ 6.1
Dimaly123 b42949f
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_M…
Dimaly123 e273ef8
ДЗ 6.1 Edit1
Dimaly123 b60f045
ДЗ 5.1 Edit3
Dimaly123 35c8672
ДЗ 5.1 Edit4
Dimaly123 75e60af
ДЗ 5.3
Dimaly123 f5776a7
ДЗ 5.3 Edit1
Dimaly123 3be7ad2
ДЗ 6.1 Edit1
Dimaly123 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,30 @@ | ||
|
|
||
| # def min_el(arr): | ||
| # for i in range(len(arr)): | ||
| # for k in range(i): | ||
| # if arr[k] > arr[i]: | ||
| # arr[k],arr[i] = arr[i],arr[k] | ||
| # return arr | ||
|
|
||
|
|
||
|
|
||
| # print(arr) | ||
| # print(min_el(arr)) | ||
|
|
||
|
|
||
| arr = [0, 3, 24, 2, 3, 7] | ||
|
|
||
| i = 0 | ||
| while i < len(arr)-1: | ||
| m = i | ||
| j = i + 1 | ||
|
|
||
| while j < len(arr): | ||
| if arr[j] < arr[m]: | ||
| m = j | ||
| j = j+1 | ||
| if m != i: | ||
| arr[i], arr[m] = arr[m], arr[i] | ||
| i += 1 | ||
|
|
||
| print(arr) | ||
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 @@ | ||
| def povtor(lst): | ||
| for i in range(len(lst)): | ||
| for k in range(i): | ||
| if lst[i] == lst[k]: | ||
| return lst[i] | ||
|
|
||
|
|
||
| lst = [2, 3, 4, 5, 3, 2] | ||
| print(povtor(lst)) |
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,11 @@ | ||
|
|
||
| d = {"Зимой" : "Щи", "летом" : "каша", "одним" : "пища", "цветом" : "наша"} | ||
| st_r = "Зимой и летом одним цветом" | ||
|
|
||
| print(f"Было: ", st_r) | ||
|
|
||
| for k,v in d.items(): | ||
| st_r = st_r.replace(k,v) | ||
| print(k,v) | ||
|
|
||
| print(f"Стало: ", st_r) |
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,42 @@ | ||
|
|
||
| class Tanks: | ||
| country = "" | ||
| name = "" | ||
| hp = 0 # Прочность | ||
| dmg = 0 # Урон | ||
|
|
||
| def __init__(self, country_, name_): | ||
| self.country = country_ | ||
| self.name = name_ | ||
|
|
||
|
IlyaOrlov marked this conversation as resolved.
|
||
| def add_hp(self, increase): | ||
| self.hp += increase | ||
|
|
||
| def add_dmg(self, incr): | ||
| self.dmg += incr | ||
|
|
||
| def in_game(self): | ||
| print(f"In Game {self.name} from {self.country}") | ||
|
|
||
|
|
||
| t1 = Tanks("rus", "T-90M «Прорыв»") | ||
| t1.add_hp(90) | ||
| t1.add_dmg(30) | ||
|
|
||
| t2 = Tanks("ger","Leopard" ) | ||
| t2.add_hp(60) | ||
| t2.add_dmg(20) | ||
|
|
||
| t3 = Tanks("usa","M1 Abrams" ) | ||
| t3.add_hp(50) | ||
| t3.add_dmg(10) | ||
|
|
||
| for i in [t1,t2,t3]: | ||
| i.in_game() | ||
| print(f"{i.hp = },{i.dmg = }") | ||
| print("**********************") | ||
| # t2.in_game() | ||
| # print(f"{t2.hp = },{t2.dmg = }") | ||
| # print("**********************") | ||
| # t3.in_game() | ||
| # print(f"{t3.hp = },{t3.dmg = }") | ||
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.
j += 1