-
Notifications
You must be signed in to change notification settings - Fork 0
Katrashova branch #72
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
KseniaKatrashova
wants to merge
27
commits into
main
Choose a base branch
from
KatrashovaBranch
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
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
dc1b77e
4.5
KseniaKatrashova 04b6123
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova 67a7f57
4.5
KseniaKatrashova 9a321f9
4.6
KseniaKatrashova 6af927c
4.8
KseniaKatrashova aa26a35
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova 7c630ce
4.7
KseniaKatrashova 45092e1
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova 7d53613
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova 1d9d456
5.1
KseniaKatrashova e3b3eab
5.1 and 5.2
KseniaKatrashova 3e2aa9b
задания по 5 лекции
KseniaKatrashova 97d7437
исправление и задания 6
KseniaKatrashova f0d8599
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova ff49008
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova 65c81bc
лекция 7
KseniaKatrashova 0fe3af9
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova c779204
лекция 8
KseniaKatrashova b0c13ea
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova a4d356e
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova b22793a
Merge branch 'main' of https://github.com/IlyaOrlov/PythonCourse2.0_A…
KseniaKatrashova dfc5306
func в переменную и возвращаем
KseniaKatrashova 7dc211c
исправлено
KseniaKatrashova 4e491eb
исправлено
KseniaKatrashova 5d191cf
Delete task_5.py
KseniaKatrashova f7af689
Delete task5.1.py
KseniaKatrashova 63edb1f
Delete Task 03.py
KseniaKatrashova 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,23 @@ | ||
| def find_max(a, b): | ||
| if a > b: | ||
| return a | ||
| elif a < b: | ||
| return b | ||
| else: | ||
| print("Числа равны") | ||
| x = int(input("Введите число a: ")) | ||
| y = int(input("Введите число b: ")) | ||
| res = find_max(x, y) | ||
| print(f"Большее число: {res}") | ||
|
|
||
|
|
||
| def print_max(a, b): | ||
| if a > b: | ||
| print(a) | ||
| elif a < b: | ||
| print(b) | ||
| else: | ||
| print("Числа равны") | ||
| x = int(input("Введите число a: ")) | ||
| y = int(input("Введите число b: ")) | ||
| print_max(x, y) | ||
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,12 @@ | ||
| def my_decor(func): | ||
| def wrapper(): | ||
| print("===========") | ||
| res = func() | ||
| print("===========") | ||
| return res | ||
| return wrapper | ||
|
|
||
| def my_func(): | ||
| print("Тут основная функция") | ||
| my = my_decor(my_func) | ||
| my() |
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,26 @@ | ||
| import random | ||
|
|
||
| print("Давай сыграем в камень, ножницы, бумага") | ||
| x = ("камень", "ножницы", "бумага") | ||
|
|
||
| while True: | ||
| y = input("Твой выбор - камень, ножницы, бумага: ") | ||
| comp = random.choice(x) | ||
| print(f"Вы выбрали {y}, компьютер выбрал {comp}.") | ||
| if y == comp: | ||
| print("Ничья!") | ||
| elif y == "камень": | ||
| if comp == "ножницы": | ||
| print("Ты победил!") | ||
| else: | ||
| print("Ты проиграл.") | ||
| elif y == "бумага": | ||
| if comp == "камень": | ||
| print("Ты победил!") | ||
| else: | ||
| print("Ты проиграл.") | ||
| elif y == "ножницы": | ||
| if comp == "бумага": | ||
| print("Ты победил!") | ||
| else: | ||
| 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,14 @@ | ||
|
|
||
| def arr_sort(arr): | ||
| for i in range(len(arr)): | ||
| m = i | ||
| for j in range(i + 1, len(arr)): | ||
| if arr[j] < arr[m]: | ||
| m = j | ||
| if i != m: | ||
| arr[i], arr[m] = arr[m], arr[i] | ||
|
|
||
| array = [0, 3, 24, 2, 3, 7] | ||
|
|
||
| arr_sort(array) | ||
| print(array) |
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,12 @@ | ||
| def fun(my_list): | ||
| new_set = set() | ||
| for i in my_list: | ||
| if i in new_set: | ||
| print(f'Первый повторившийся символ: {my_list[i]} ') | ||
| break | ||
| else: | ||
| new_set.add(my_list[i]) | ||
|
|
||
|
|
||
| lst = [2, 3, 4, 5, 3, 2] | ||
| fun(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,7 @@ | ||
| s ="Белеет парус одинокой \nв тумане моря голубом!.." | ||
| d = {"Белеет": "one", "парус": "two", "моря": "three"} | ||
|
|
||
| print(f"До:\n{s}") | ||
| for i, value in d.items(): | ||
| s = s.replace(i, value) | ||
| print(f"После:\n{s}") |
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,27 @@ | ||
| def search(ls, a): | ||
| ind = set() | ||
| for i in range(len(ls)): | ||
| for m in range(len(ls[i])): | ||
| if a == ls[i][m]: | ||
| ind.add(m) | ||
| ind = list(ind) | ||
| return ind | ||
|
|
||
|
|
||
| def delete(my_lst, lst_to_remove): | ||
| for i in range(len(my_lst)): | ||
| for n in reversed(lst_to_remove): | ||
| del my_lst[i][n] | ||
| return my_lst | ||
|
|
||
|
|
||
| lst = [ | ||
| [1, 2, 3, 4, 5, 6, 7], | ||
| [1, 1, 1, 2, 3, 4, 4], | ||
| [2, 2, 1, 3, 3, 5, 6] | ||
| ] | ||
|
|
||
| d = int(input("Ведите цифру для удаления стобцов( от 1 до 7): ")) | ||
| res = search(lst, d) | ||
| res2 = delete(lst, res) | ||
| print(f"Удалил: {res2}") |
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,10 @@ | ||
| with open("text.txt", "r") as fo: | ||
| reading = fo.read() | ||
| my_choice = input("Что заменить? 1 - табуляция на пробелы, 2 - пробелы на табуляцию \n") | ||
|
|
||
| with open("text.txt", "w") as fw: | ||
| if my_choice == "1": | ||
| fw.write(reading.replace("\t", " ")) | ||
| elif my_choice == "2": | ||
| fw.write(reading.replace(" ", "\t")) | ||
| 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,3 @@ | ||
| There are different kinds of animals on our planet, and all of them are very important for it. | ||
| For example, everybody knows that the sharks are dangerous for people, but they are useful for cleaning seawater. | ||
| There are two types of animals: domestic (or pets) and wild. |
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,23 @@ | ||
| class Tank(): | ||
| def __init__(self, name, crew, weight): | ||
| self.name = name | ||
| self.crew = crew | ||
| self.weight = weight | ||
|
|
||
| def show(self): | ||
| print(f"Танк {self.name} экипажем {self.crew} человек(а), и массой {self.weight}") | ||
|
|
||
| def __lt__(self, other): | ||
|
Owner
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. Метод |
||
| if self.weight > other.weight: | ||
| print(f'У Игрока {self.name} больше шансов') | ||
| elif self.weight == other.weight: | ||
| print('Шансы равны') | ||
| else: | ||
| print(f'У Игрока {self.name} меньше шансов') | ||
|
|
||
|
|
||
| player1 = Tank('T-80', 3, 40) | ||
| player2 = Tank('T-34', 4, 30) | ||
| lst = [player1, player2] | ||
| for i in lst: | ||
| i.show() | ||
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,41 @@ | ||
| class Duck: | ||
| color = "белый" | ||
|
|
||
| def __init__(self, name, weight): | ||
| self.name = name | ||
| self.weight = weight | ||
|
|
||
| @staticmethod | ||
| def crack(): | ||
| print("Сrack") | ||
|
|
||
| @classmethod | ||
| def color_duck(cls): | ||
| print(f"Цвет утки {cls.color}") | ||
|
|
||
| def __repr__(self): | ||
| return f"Имя утки: {self.name}, вес {self.weight} кг" | ||
|
|
||
| def __lt__(self, other): | ||
| if self.weight < other.weight: | ||
| return f"Утка {other.name} тяжелее" | ||
| else: | ||
| return f"Утка {self.name} тяжелее" | ||
|
|
||
| def __ne__(self, other): | ||
| return self.weight != other.weight | ||
|
|
||
| def __add__(self, other): | ||
| return self.weight + other.weight | ||
|
|
||
|
|
||
| duck1 = Duck("Катя", 4) | ||
| duck2 = Duck("Вика", 5) | ||
|
|
||
| duck1.crack() | ||
| duck2.color_duck() | ||
| print(duck1) | ||
| print(duck2) | ||
| print(duck1 < duck2) | ||
| print(duck1 != duck2) | ||
| print(f"Общий вес уток {duck1 + duck2} кг") |
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,33 @@ | ||
| import tempfile | ||
| import os | ||
|
|
||
|
|
||
| class WrapStrToFile: | ||
| def __init__(self): | ||
| self._filepath = tempfile.mktemp() | ||
|
|
||
| @property | ||
| def content(self): | ||
| try: | ||
| with open(self._filepath, 'r') as f: | ||
| return f.read() | ||
| except Exception: | ||
| return 'Файл еще не существует' | ||
|
|
||
| @content.setter | ||
| def content(self, value): | ||
| with open(self._filepath, 'w') as f: | ||
| f.write(value) | ||
|
|
||
| @content.deleter | ||
| def content(self): | ||
| os.remove(self._filepath) | ||
|
|
||
|
|
||
| a = WrapStrToFile() | ||
| print(a.content) # Output: File doesn't exist | ||
| a.content = 'test str' | ||
| print(a.content) # Output: test_str | ||
| a.content = 'text 2' | ||
| print(a.content) # Output: text 2 | ||
| del a.content # после этого файла не существует |
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 @@ | ||
| class Man: | ||
| def __init__(self, name): | ||
| self.name = name | ||
|
|
||
| def solve_task(self): | ||
| print("I'm not ready yet") | ||
|
|
||
| man = Man('Альберт') | ||
| man.solve_task() |
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,21 @@ | ||
| import time | ||
| import random | ||
|
|
||
| class Man: | ||
|
|
||
| def __init__(self, name): | ||
| self.name = name | ||
| def solve_task(self): | ||
| print("I'm not ready yet") | ||
|
|
||
| class Pupil(Man): | ||
| def solve_task(self): | ||
| delay = random.randint(3, 6) | ||
| time.sleep(delay) | ||
| super().solve_task() | ||
|
|
||
|
|
||
| man = Man("Альберт") | ||
| pupil = Pupil("Арнольд") | ||
| man.solve_task() | ||
| pupil.solve_task() |
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 @@ | ||
| class Iter: | ||
|
|
||
| def __init__(self, text, my_sim): | ||
| self.text = text | ||
| self.my_sim = my_sim | ||
|
|
||
| def __iter__(self): | ||
| return self | ||
|
|
||
| def __next__(self): | ||
| my_str = ' ' | ||
| new_str = '' | ||
| while my_str != '': | ||
| my_str = self.text.read(1) | ||
| if my_str == self.my_sim: | ||
| break | ||
| else: | ||
| new_str += my_str | ||
|
|
||
| if new_str != '': | ||
| return new_str | ||
| else: | ||
| raise StopIteration | ||
|
|
||
|
|
||
|
|
||
|
|
||
| with open('text.txt', 'r') as f: | ||
| for i in Iter(f, '§'): | ||
| print(i) |
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 @@ | ||
| def my_gen(file): | ||
| with open(file, 'r', encoding='utf8') as f: | ||
| for s in f: | ||
| yield s | ||
|
|
||
|
|
||
| for i in my_gen('text.txt'): | ||
| print(i) |
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 time | ||
|
|
||
| class Wait: | ||
| def __init__(self): | ||
| self.begint = 0 | ||
|
|
||
| def __enter__(self): | ||
| self.begint = time.time() | ||
| return self | ||
|
|
||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| print(f"Around time: {time.time() - self.begint} seconds") | ||
|
|
||
| with Wait(): | ||
| arr = [] | ||
| for i in range(1, 10000000): | ||
| arr.append(i**2) |
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,18 @@ | ||
| import itertools | ||
|
|
||
|
|
||
| def arr(num1, num2, num3): | ||
| joint = list(itertools.chain(num1, num2, num3)) | ||
| return joint | ||
|
|
||
| def less(lst): | ||
| filtered = list(itertools.filterfalse(lambda x: len(x) != 5, lst)) | ||
| return filtered | ||
|
|
||
| def key(string, r): | ||
| passwords = list(itertools.combinations(string, r)) | ||
| return passwords | ||
|
|
||
| print(arr([1, 2, 3], [4, 5], [6, 7])) | ||
| print(less(['hello', 'i', 'write', 'cool', 'code'])) | ||
| print(key('password', 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 @@ | ||
| § It goes without saying, books are our teachers and friends. They teach us to be kind, clever, polite, hardworking, friendly. | ||
| § Books help us to learn more about nature, the world around us and many other interesting things.There are a lot of books on history, about animals, travellers, children, school and so on. | ||
| § Children like to read adventure and magic books, science fiction and detective stories. | ||
| § They enjoy stories, short stories, novels, fairy-tales, fables and poems. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.