From 4d1e4209291f33b4728eef51f70b7d07921e3080 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Sun, 24 Sep 2023 21:34:39 +0300 Subject: [PATCH 01/29] =?UTF-8?q?=D0=97=D0=B0=D0=BC=D0=B5=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B0,=20=D1=87=D1=82=D0=BE=20=D1=83=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=8F=20=D1=82=D1=83=D1=82=20=D0=B2=D1=8B=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=B5=D0=BD=D0=BD=D0=BE=D0=B5=20=D0=B7=D0=B0=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=B2=D0=B0=D0=BB=D1=8F?= =?UTF-8?q?=D0=BB=D0=BE=D1=81=D1=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\320\270\320\263\321\200\320\260.py" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "Practice/tshyregena/\320\270\320\263\321\200\320\260.py" diff --git "a/Practice/tshyregena/\320\270\320\263\321\200\320\260.py" "b/Practice/tshyregena/\320\270\320\263\321\200\320\260.py" new file mode 100644 index 00000000..e28c34f8 --- /dev/null +++ "b/Practice/tshyregena/\320\270\320\263\321\200\320\260.py" @@ -0,0 +1,23 @@ +import random + + +lst = ["камень", "ножницы", "бумага"] +choice = random.choice(lst) +print(f"Приветствую тебя, я хочу сыграть с тобой в игру!") +p = input("Введите камень, ножницы или бумагу: ").lower() +if p == choice: + print("Ничья!") +elif p == "камень" and choice == "ножницы": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") +elif p == "ножницы" and choice == "камень": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы проиграли") +elif p == "ножницы" and choice == "бумага": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") +elif p == "бумага" and choice == "ножницы": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы проиграли") +elif p == "бумага" and choice == "камень": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") +elif p == "камень" and choice == "бумага": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") +else: + print("Вы ввели что-то не то") From 7a14f5acc0c1614f461b8b2d7c6177b4b8525870 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Sun, 24 Sep 2023 21:49:53 +0300 Subject: [PATCH 02/29] =?UTF-8?q?=D0=98=20=D1=8D=D1=82=D0=BE=20=D1=82?= =?UTF-8?q?=D0=BE=D0=B6=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\321\200\320\260\321\202\320\276\321\200.py" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" diff --git "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" new file mode 100644 index 00000000..1d4a80be --- /dev/null +++ "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" @@ -0,0 +1,17 @@ +def fun_dec(fun): + def fun_nuw(*args): + print("="*10) + print(max(args)) + print("="*10) + + return fun_nuw + + +@fun_dec +def fun(*args): + print(max(args)) + + +a = int(input("Введите первое число: ")) +b = int(input("Введите второе число: ")) +fun(a, b) From ed1cc170e1ca0ee5328ca073a250eef5d2755163 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Sat, 30 Sep 2023 00:31:35 +0300 Subject: [PATCH 03/29] =?UTF-8?q?=D0=9F=D0=BE=D0=BA=D0=B0=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20\276\321\200\320\270\321\202\320\274.py" | 8 +++++++ ...20\267\320\262\321\200\320\260\321\202.py" | 13 ++++++++++++ ...21\202\321\200\320\270\321\206\320\260.py" | 21 +++++++++++++++++++ ...20\276\320\262\320\260\321\200\321\214.py" | 5 +++++ 4 files changed, 47 insertions(+) create mode 100644 "Practice/tshyregena/\320\260\320\273\320\263\320\276\321\200\320\270\321\202\320\274.py" create mode 100644 "Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" create mode 100644 "Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" create mode 100644 "Practice/tshyregena/\321\201\320\273\320\276\320\262\320\260\321\200\321\214.py" diff --git "a/Practice/tshyregena/\320\260\320\273\320\263\320\276\321\200\320\270\321\202\320\274.py" "b/Practice/tshyregena/\320\260\320\273\320\263\320\276\321\200\320\270\321\202\320\274.py" new file mode 100644 index 00000000..49119b75 --- /dev/null +++ "b/Practice/tshyregena/\320\260\320\273\320\263\320\276\321\200\320\270\321\202\320\274.py" @@ -0,0 +1,8 @@ +lst = [5, 78, 4, 34] +for k in range(len(lst)): + nM = k + for i in range(k, len(lst)): + if lst[i] < lst[nM]: + nM = i + lst[k], lst[nM] = lst[nM], lst[k] +print(lst) diff --git "a/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" "b/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" new file mode 100644 index 00000000..fa94652e --- /dev/null +++ "b/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" @@ -0,0 +1,13 @@ +def fun(lst): + res = [] + for element in lst: + while lst.count(element) > 1 and element not in res: + if len(res) == 0: + res.append(element) + else: + break + return res + + +lst = [5, 78, 8, 25, 8, 5] +print(fun(lst)) diff --git "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" new file mode 100644 index 00000000..1fe2959b --- /dev/null +++ "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" @@ -0,0 +1,21 @@ + +def display(matrix1): + for r in matrix1: + print(r) + + +matrix = [[5, 4, 3], + [6, 6, 7], + [3, 9, 0]] +row1 = [matrix[0][0], matrix[1][0], matrix[2][0]] +row2 = [matrix[0][1], matrix[1][1], matrix[2][1]] +row3 = [matrix[0][2], matrix[1][2], matrix[2][2]] +p = int(input("Какое число вы хотите удалить: ")) +if p in row1: + del [matrix[0][0], matrix[1][0], matrix[2][0]] +if p in row2: + del [matrix[0][1], matrix[1][1], matrix[2][1]] +if p in row3: + del [matrix[0][2], matrix[1][2], matrix[2][2]] +matrix1 = matrix +print(display(matrix1)) diff --git "a/Practice/tshyregena/\321\201\320\273\320\276\320\262\320\260\321\200\321\214.py" "b/Practice/tshyregena/\321\201\320\273\320\276\320\262\320\260\321\200\321\214.py" new file mode 100644 index 00000000..4bf6d571 --- /dev/null +++ "b/Practice/tshyregena/\321\201\320\273\320\276\320\262\320\260\321\200\321\214.py" @@ -0,0 +1,5 @@ +kidd = "Кошка мяукает. Собака лает. Птичка чирикает. Лягушка квакает." +a = dict(мяукает='говорит - мяу', лает='говорит - гав', чирикает='говорит - чирик-чирик', квакает='говорит - ква-ква') +for key, value in a.items(): + kidd = kidd.replace(key, value) +print(kidd) From 9c6fd6b0204238e1069c5034a60418fe79e8f687 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Thu, 5 Oct 2023 15:15:37 +0300 Subject: [PATCH 04/29] =?UTF-8?q?=D0=9A=D0=B0=D0=BA=20=D0=BF=D0=BE=D0=BD?= =?UTF-8?q?=D1=8F=D0=BB=D0=B0=3F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Practice/tshyregena/\321\202\320\260\320\261.py" | 9 +++++++++ "Practice/tshyregena/\321\202\320\260\320\261.txt" | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 "Practice/tshyregena/\321\202\320\260\320\261.py" create mode 100644 "Practice/tshyregena/\321\202\320\260\320\261.txt" diff --git "a/Practice/tshyregena/\321\202\320\260\320\261.py" "b/Practice/tshyregena/\321\202\320\260\320\261.py" new file mode 100644 index 00000000..06fddfb5 --- /dev/null +++ "b/Practice/tshyregena/\321\202\320\260\320\261.py" @@ -0,0 +1,9 @@ +with open("таб.txt", "r", encoding="utf-8") as f: + s = f.read() + p = input("Свернуть или развернуть символы табуляции: ").lower() + k = "" + if p == "свернуть": + k = s.replace(' ', '\t') + else: + print(s) + print(k) diff --git "a/Practice/tshyregena/\321\202\320\260\320\261.txt" "b/Practice/tshyregena/\321\202\320\260\320\261.txt" new file mode 100644 index 00000000..863667a3 --- /dev/null +++ "b/Practice/tshyregena/\321\202\320\260\320\261.txt" @@ -0,0 +1,8 @@ + Кто любит Бога - церковь чтит, + Хмельное не бодрит - дурманит, + Деньга деньгу сама родит, + Тот не продаст, кто не обманет, + Охотник кормит псов заране, + Терпенье города бедёт + И стену всякую таранит, + Кто ищет тот всегда найдёт. \ No newline at end of file From e6b5ba8803bdf38074da8563cab8a361b11d66ec Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 11 Oct 2023 22:13:05 +0300 Subject: [PATCH 05/29] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20\260\321\200\320\265\320\275\321\214.py" | 26 ++++++++ ...21\202\320\260\320\275\320\272\320\270.py" | 17 ++++++ .../\321\203\321\202\320\272\320\270.py" | 60 +++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 "Practice/tshyregena/\321\201\320\277\321\217\321\211\320\270\320\271 \320\277\320\260\321\200\320\265\320\275\321\214.py" create mode 100644 "Practice/tshyregena/\321\202\320\260\320\275\320\272\320\270.py" create mode 100644 "Practice/tshyregena/\321\203\321\202\320\272\320\270.py" diff --git "a/Practice/tshyregena/\321\201\320\277\321\217\321\211\320\270\320\271 \320\277\320\260\321\200\320\265\320\275\321\214.py" "b/Practice/tshyregena/\321\201\320\277\321\217\321\211\320\270\320\271 \320\277\320\260\321\200\320\265\320\275\321\214.py" new file mode 100644 index 00000000..543b69e1 --- /dev/null +++ "b/Practice/tshyregena/\321\201\320\277\321\217\321\211\320\270\320\271 \320\277\320\260\321\200\320\265\320\275\321\214.py" @@ -0,0 +1,26 @@ +import time +import random + + +class Man: + def __init__(self, name): + self.name = name + + @staticmethod + def solve_task(self): + print(f"I'm not ready yet") + + +class Pupil(Man): + + @staticmethod + def solve_task(self): + r = random.randrange(3, 6) + time.sleep(r) + print(f"Я подумал {r} секунды, но я тоже не готов пока.") + + +m = Man("Гоша") +m.solve_task(m) +h = Pupil("Лев") +h.solve_task(h) diff --git "a/Practice/tshyregena/\321\202\320\260\320\275\320\272\320\270.py" "b/Practice/tshyregena/\321\202\320\260\320\275\320\272\320\270.py" new file mode 100644 index 00000000..46815b3a --- /dev/null +++ "b/Practice/tshyregena/\321\202\320\260\320\275\320\272\320\270.py" @@ -0,0 +1,17 @@ +class Tanks: + def __init__(self, name, color, armor, speed, power): + self.name = name + self.color = color + self.armor = armor + self.speed = speed + self.power = power + + def print_p(self): + print( + f"Я персонаж {id(self)}: {self.name=}, мой цвет {self.color=}. Моя броня {self.armor=}\n и я двигаюсь я со скоростью {self.speed=}. Моя сила {self.power=}") + + +p1 = Tanks('Рыжик', "синий", '50', "4", 100) +p1.print_p() # Employee.print_emp(e1) +p2 = Tanks('Лина', 'розовый', '60', '150', '500') +p2.print_p() diff --git "a/Practice/tshyregena/\321\203\321\202\320\272\320\270.py" "b/Practice/tshyregena/\321\203\321\202\320\272\320\270.py" new file mode 100644 index 00000000..9ccc793a --- /dev/null +++ "b/Practice/tshyregena/\321\203\321\202\320\272\320\270.py" @@ -0,0 +1,60 @@ +class Duck: + color = "коричневый" + + def __init__(self, name, weight): + self.name = name + self.weight = weight + + @classmethod + def color_p(cls): + print(f"Цвета уток в корзинке {cls.color}") + + def print_p(self): + print( + f"Я вешу {self.weight} грамм. Меня зовут {self.name}") + + @staticmethod + def say_crack(): + print('Crack') + + def __gt__(self, other): + return self.weight > other.weight + + def __lt__(self, other): + return self.weight < other.weight + + def __ne__(self, other): + return self.weight != other.weight + + def __eq__(self, other): + return self.weight == other.weight + + def __add__(self, other): + new_weight = self.weight + other.weight + new_duck = Duck("Шпуня", new_weight) + return new_duck + + def __repr__(self): + return f"Duck at {id(self)}: {self.name=}, {self.weight=}" + + +d = Duck("Minimi", 100) +d.print_p() +d.say_crack() +d1 = Duck("Minily", 90) +d1.print_p() +d1.say_crack() +d2 = Duck("Roma", 150) +d2.print_p() +d2.say_crack() +d3 = Duck("Fufa", 190) +d3.print_p() +d3.say_crack() +Duck.color_p() +print(d > d2) +print(d1 < d2) +print(d3 != d3) +print(d2 == d2) +s = d1 + d3 +print(s.weight) +print(repr(s)) From 72a692073494d85a7a1f20d57e25c9be7150939c Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 11 Oct 2023 22:13:16 +0300 Subject: [PATCH 06/29] =?UTF-8?q?=D0=A1=D1=8E=D0=B4=D0=B0=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...21\202\321\200\320\270\321\206\320\260.py" | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" index 1fe2959b..86ef8732 100644 --- "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" +++ "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" @@ -4,18 +4,40 @@ def display(matrix1): print(r) -matrix = [[5, 4, 3], - [6, 6, 7], - [3, 9, 0]] -row1 = [matrix[0][0], matrix[1][0], matrix[2][0]] -row2 = [matrix[0][1], matrix[1][1], matrix[2][1]] -row3 = [matrix[0][2], matrix[1][2], matrix[2][2]] -p = int(input("Какое число вы хотите удалить: ")) -if p in row1: - del [matrix[0][0], matrix[1][0], matrix[2][0]] -if p in row2: - del [matrix[0][1], matrix[1][1], matrix[2][1]] -if p in row3: - del [matrix[0][2], matrix[1][2], matrix[2][2]] -matrix1 = matrix -print(display(matrix1)) +def display2(matrix3): + new_mat = [] + for i in range(len(matrix3[0])): + new_row = [] + for el in matrix3: + new_row.append(el[i]) + new_mat.append(new_row) + return new_mat + + +# matrix = [[5, 4, 3], +# [6, 6, 7], +# [3, 9, 0]] +# row1 = [matrix[0][0], matrix[1][0], matrix[2][0]] +# row2 = [matrix[0][1], matrix[1][1], matrix[2][1]] +# row3 = [matrix[0][2], matrix[1][2], matrix[2][2]] +# p = int(input("Какое число вы хотите удалить: ")) +# if p in row1: +# del [matrix[0][0], matrix[1][0], matrix[2][0]] +# if p in row2: +# del [matrix[0][1], matrix[1][1], matrix[2][1]] +# if p in row3: +# del [matrix[0][2], matrix[1][2], matrix[2][2]] +# matrix1 = matrix +# print(display(matrix1)) +matrix2 = [[5, 4, 3, 8], + [6, 6, 7, 8], + [3, 9, 0, 6]] +new_mat = display2(matrix2) +print(new_mat) +p1 = int(input("Какое число вы хотите удалить: ")) +k = [] +if p1 in new_mat[i]: + del new_mat[i] +else: + k.append(p1) +print(display(k)) From b753d8e39e6a1090b632324793afe3392ea2d6ca Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 11 Oct 2023 22:13:39 +0300 Subject: [PATCH 07/29] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20\276\321\200\320\270\321\202\320\274.py" | 3 ++- ...20\267\320\262\321\200\320\260\321\202.py" | 13 +++------ .../\320\270\320\263\321\200\320\260.py" | 27 ++++++++++--------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git "a/Practice/tshyregena/\320\260\320\273\320\263\320\276\321\200\320\270\321\202\320\274.py" "b/Practice/tshyregena/\320\260\320\273\320\263\320\276\321\200\320\270\321\202\320\274.py" index 49119b75..b07e7f40 100644 --- "a/Practice/tshyregena/\320\260\320\273\320\263\320\276\321\200\320\270\321\202\320\274.py" +++ "b/Practice/tshyregena/\320\260\320\273\320\263\320\276\321\200\320\270\321\202\320\274.py" @@ -4,5 +4,6 @@ for i in range(k, len(lst)): if lst[i] < lst[nM]: nM = i - lst[k], lst[nM] = lst[nM], lst[k] + if nM != k: + lst[k], lst[nM] = lst[nM], lst[k] print(lst) diff --git "a/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" "b/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" index fa94652e..86863368 100644 --- "a/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" +++ "b/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" @@ -1,13 +1,8 @@ def fun(lst): - res = [] for element in lst: - while lst.count(element) > 1 and element not in res: - if len(res) == 0: - res.append(element) - else: - break - return res + if lst.count(element) > 1: + return element -lst = [5, 78, 8, 25, 8, 5] -print(fun(lst)) +lst1 = [6, 78, 8, 25, 8, 5] +print(fun(lst1)) diff --git "a/Practice/tshyregena/\320\270\320\263\321\200\320\260.py" "b/Practice/tshyregena/\320\270\320\263\321\200\320\260.py" index e28c34f8..112d8cfb 100644 --- "a/Practice/tshyregena/\320\270\320\263\321\200\320\260.py" +++ "b/Practice/tshyregena/\320\270\320\263\321\200\320\260.py" @@ -7,17 +7,20 @@ p = input("Введите камень, ножницы или бумагу: ").lower() if p == choice: print("Ничья!") -elif p == "камень" and choice == "ножницы": - print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") -elif p == "ножницы" and choice == "камень": - print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы проиграли") -elif p == "ножницы" and choice == "бумага": - print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") -elif p == "бумага" and choice == "ножницы": - print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы проиграли") -elif p == "бумага" and choice == "камень": - print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") -elif p == "камень" and choice == "бумага": - print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") +elif p == "ножницы": + if choice == "камень": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы проиграли") + else: + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") +elif p == "бумага": + if choice == "камень": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") + else: + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы проиграли") +elif p == "камень": + if choice == "ножницы": + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы выйграли") + else: + print(f"Ваш выбор: {p}, выбор компьютера: {choice}. Вы проиграли") else: print("Вы ввели что-то не то") From 52286269f2ed3efa9730a0975b0fd5bc2d8afd00 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 11 Oct 2023 22:13:54 +0300 Subject: [PATCH 08/29] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0,=20=D0=BD=D0=BE=20=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=BB=D0=B8=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2\320\276\321\200\320\260\321\202\320\276\321\200.py" | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" index 1d4a80be..7f5e827d 100644 --- "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" +++ "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" @@ -1,17 +1,18 @@ def fun_dec(fun): def fun_nuw(*args): print("="*10) - print(max(args)) + res = fun(*args) + print(res) print("="*10) return fun_nuw @fun_dec -def fun(*args): - print(max(args)) +def fun1(*args): + return max(args) a = int(input("Введите первое число: ")) b = int(input("Введите второе число: ")) -fun(a, b) +fun1(a, b) From 51a8e3813dab2fa818f206ac0c3e12b9408173ee Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 11 Oct 2023 22:14:21 +0300 Subject: [PATCH 09/29] =?UTF-8?q?=D0=9D=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=87=D0=B8=D0=B9,=20=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=BD=D0=B8?= =?UTF-8?q?=D0=BC=D0=B0=D1=8E=20=D1=87=D1=82=D0=BE=20=D0=B5=D0=BC=D1=83=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BD=D1=80=D0=B0=D0=B2=D0=B8=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/tshyregena/WrapStrToFIle.py | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Practice/tshyregena/WrapStrToFIle.py diff --git a/Practice/tshyregena/WrapStrToFIle.py b/Practice/tshyregena/WrapStrToFIle.py new file mode 100644 index 00000000..bd15f19d --- /dev/null +++ b/Practice/tshyregena/WrapStrToFIle.py @@ -0,0 +1,33 @@ +import tempfile +import os + + +class WrapStrToFile: + def __init__(self): + self._filepath = tempfile.mkstemp() + + @property + def content(self): + try: + with open(self._filepath, "r", encoding="utf-8") as file1: + return file1.read() + except FileNotFoundError: + return 'File doesnt exist' + + @content.setter + def content(self, value): + with open(self._filepath, "w", encoding="utf-8") as file1: + file1.write(value) + + @content.deleter + def content(self): + os.remove(self._filepath) + + +wstf = WrapStrToFile() +print(wstf.content) # Output: File doesn't exist +wstf.content = 'test str' +print(wstf.content) # Output: test_str +wstf.content = 'text 2' +print(wstf.content) # Output: text 2 +del wstf.content From 8055d2fffaa84452499ef2ca6787672900fe45b7 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Thu, 12 Oct 2023 23:18:22 +0300 Subject: [PATCH 10/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1 \320\277\320\260\321\200\320\265\320\275\321\214.py" | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git "a/Practice/tshyregena/\321\201\320\277\321\217\321\211\320\270\320\271 \320\277\320\260\321\200\320\265\320\275\321\214.py" "b/Practice/tshyregena/\321\201\320\277\321\217\321\211\320\270\320\271 \320\277\320\260\321\200\320\265\320\275\321\214.py" index 543b69e1..cc9406c3 100644 --- "a/Practice/tshyregena/\321\201\320\277\321\217\321\211\320\270\320\271 \320\277\320\260\321\200\320\265\320\275\321\214.py" +++ "b/Practice/tshyregena/\321\201\320\277\321\217\321\211\320\270\320\271 \320\277\320\260\321\200\320\265\320\275\321\214.py" @@ -7,20 +7,20 @@ def __init__(self, name): self.name = name @staticmethod - def solve_task(self): + def solve_task(): print(f"I'm not ready yet") class Pupil(Man): @staticmethod - def solve_task(self): + def solve_task(): r = random.randrange(3, 6) time.sleep(r) print(f"Я подумал {r} секунды, но я тоже не готов пока.") m = Man("Гоша") -m.solve_task(m) +m.solve_task() h = Pupil("Лев") -h.solve_task(h) +h.solve_task() From b4c0432db08b3e4a4e1a34924946a52dd7293633 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Thu, 12 Oct 2023 23:18:32 +0300 Subject: [PATCH 11/29] =?UTF-8?q?=D0=92=D1=8B=20=D0=BF=D1=80=D0=BE=20?= =?UTF-8?q?=D1=8D=D1=82=D0=BE=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Practice/tshyregena/\321\203\321\202\320\272\320\270.py" | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git "a/Practice/tshyregena/\321\203\321\202\320\272\320\270.py" "b/Practice/tshyregena/\321\203\321\202\320\272\320\270.py" index 9ccc793a..8cfe6a7b 100644 --- "a/Practice/tshyregena/\321\203\321\202\320\272\320\270.py" +++ "b/Practice/tshyregena/\321\203\321\202\320\272\320\270.py" @@ -7,11 +7,10 @@ def __init__(self, name, weight): @classmethod def color_p(cls): - print(f"Цвета уток в корзинке {cls.color}") + print(f"Цвет уток в корзинке {cls.color}") def print_p(self): - print( - f"Я вешу {self.weight} грамм. Меня зовут {self.name}") + print(f"Я вешу {self.weight} грамм. Меня зовут {self.name}") @staticmethod def say_crack(): From 03b2e74e544b85234db7655d690cb4bc3f6890b2 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Thu, 12 Oct 2023 23:18:49 +0300 Subject: [PATCH 12/29] =?UTF-8?q?=D0=92=D1=80=D0=BE=D0=B4=D0=B5=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\321\202\321\200\320\270\321\206\320\260.py" | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" index 86ef8732..a074c9c8 100644 --- "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" +++ "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" @@ -6,7 +6,7 @@ def display(matrix1): def display2(matrix3): new_mat = [] - for i in range(len(matrix3[0])): + for k in range(len(matrix3[0])): new_row = [] for el in matrix3: new_row.append(el[i]) @@ -28,16 +28,17 @@ def display2(matrix3): # if p in row3: # del [matrix[0][2], matrix[1][2], matrix[2][2]] # matrix1 = matrix -# print(display(matrix1)) +# display(matrix1) matrix2 = [[5, 4, 3, 8], [6, 6, 7, 8], [3, 9, 0, 6]] new_mat = display2(matrix2) print(new_mat) p1 = int(input("Какое число вы хотите удалить: ")) -k = [] -if p1 in new_mat[i]: - del new_mat[i] -else: - k.append(p1) -print(display(k)) +i = 0 +while i < len(new_mat): + if p1 in new_mat[i]: + del new_mat[i] + else: + i += 1 +display(new_mat) From 6049a8f92ae7d8f5b4709029e584bd892924eade Mon Sep 17 00:00:00 2001 From: Shyregena Date: Thu, 12 Oct 2023 23:19:20 +0300 Subject: [PATCH 13/29] =?UTF-8?q?=D0=A2=D0=B0=D0=BA=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" | 1 - 1 file changed, 1 deletion(-) diff --git "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" index 7f5e827d..1b08da67 100644 --- "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" +++ "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" @@ -4,7 +4,6 @@ def fun_nuw(*args): res = fun(*args) print(res) print("="*10) - return fun_nuw From 5b860590fb4670dc798a8e105825d435e1f08059 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Fri, 13 Oct 2023 21:54:38 +0300 Subject: [PATCH 14/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0=20=D0=B2=2012=D1=81=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...260\321\202\321\200\320\270\321\206\320\260.py" | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" index a074c9c8..90865cae 100644 --- "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" +++ "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" @@ -9,7 +9,7 @@ def display2(matrix3): for k in range(len(matrix3[0])): new_row = [] for el in matrix3: - new_row.append(el[i]) + new_row.append(el[k]) new_mat.append(new_row) return new_mat @@ -32,13 +32,13 @@ def display2(matrix3): matrix2 = [[5, 4, 3, 8], [6, 6, 7, 8], [3, 9, 0, 6]] -new_mat = display2(matrix2) -print(new_mat) +new_mat1 = display2(matrix2) +print(new_mat1) p1 = int(input("Какое число вы хотите удалить: ")) i = 0 -while i < len(new_mat): - if p1 in new_mat[i]: - del new_mat[i] +while i < len(new_mat1): + if p1 in new_mat1[i]: + del new_mat1[i] else: i += 1 -display(new_mat) +display(new_mat1) From 62668b28eb19165f7ad2f3f02455cb2ac7d75b10 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Fri, 13 Oct 2023 21:54:49 +0300 Subject: [PATCH 15/29] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20\272\320\276\321\200\320\260\321\202\320\276\321\200.py" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" index 1b08da67..20a900c8 100644 --- "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" +++ "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" @@ -1,7 +1,7 @@ def fun_dec(fun): - def fun_nuw(*args): + def fun_nuw(*args, **kwargs): print("="*10) - res = fun(*args) + res = fun(*args, **kwargs) print(res) print("="*10) return fun_nuw From 1ce55831468ebf118fb3d47e817fb9586e7dc8de Mon Sep 17 00:00:00 2001 From: Shyregena Date: Fri, 13 Oct 2023 22:21:42 +0300 Subject: [PATCH 16/29] =?UTF-8?q?=D0=A2=D0=B0=D0=BA=20=D0=BB=D1=83=D1=87?= =?UTF-8?q?=D1=88=D0=B5=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Practice/tshyregena/\321\202\320\260\320\261.py" | 6 +++--- "Practice/tshyregena/\321\202\320\260\320\261.txt" | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git "a/Practice/tshyregena/\321\202\320\260\320\261.py" "b/Practice/tshyregena/\321\202\320\260\320\261.py" index 06fddfb5..8eb70a3c 100644 --- "a/Practice/tshyregena/\321\202\320\260\320\261.py" +++ "b/Practice/tshyregena/\321\202\320\260\320\261.py" @@ -1,9 +1,9 @@ -with open("таб.txt", "r", encoding="utf-8") as f: +with open("таб.txt", "r+", encoding="utf-8") as f: s = f.read() p = input("Свернуть или развернуть символы табуляции: ").lower() k = "" if p == "свернуть": - k = s.replace(' ', '\t') + k = s.replace('\t', ' ') + f.write(k) else: print(s) - print(k) diff --git "a/Practice/tshyregena/\321\202\320\260\320\261.txt" "b/Practice/tshyregena/\321\202\320\260\320\261.txt" index 863667a3..79a64623 100644 --- "a/Practice/tshyregena/\321\202\320\260\320\261.txt" +++ "b/Practice/tshyregena/\321\202\320\260\320\261.txt" @@ -5,4 +5,11 @@ Охотник кормит псов заране, Терпенье города бедёт И стену всякую таранит, + Кто ищет тот всегда найдёт. Кто любит Бога - церковь чтит, + Хмельное не бодрит - дурманит, + Деньга деньгу сама родит, + Тот не продаст, кто не обманет, + Охотник кормит псов заране, + Терпенье города бедёт + И стену всякую таранит, Кто ищет тот всегда найдёт. \ No newline at end of file From bac5ee72b12b9d9db9f9628a258d645fb21b73e3 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Mon, 16 Oct 2023 15:21:29 +0300 Subject: [PATCH 17/29] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BD=D1=8F=D1=82=D0=BD=D0=BE.=20=D0=95=D1=81?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=B7=D0=B0=20for=20=D0=BF=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D1=8F=D1=82=D1=8C=20next,=20?= =?UTF-8?q?=D1=82=D0=BE=20=D1=8D=D1=82=D0=BE=20=D0=B7=D0=BD=D0=B0=D1=87?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=BF=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=B3=D0=B0=D0=B5=D1=82=20=D0=B2=20=D0=BF=D0=BE=D0=BD?= =?UTF-8?q?=D0=B8=D0=BC=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8?= =?UTF-8?q?=D0=BA=D0=B8=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...262\320\276\320\267\320\262\321\200\320\260\321\202.py" | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git "a/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" "b/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" index 86863368..fcddc45f 100644 --- "a/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" +++ "b/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" @@ -1,8 +1,11 @@ def fun(lst): + res = [] for element in lst: - if lst.count(element) > 1: + if element in res: return element + else: + res.append(element) -lst1 = [6, 78, 8, 25, 8, 5] +lst1 = [3, 9, 8, 3, 1, 8, 6] print(fun(lst1)) From 271c0c3de3791887ad3a0e6b197786fadbe5368b Mon Sep 17 00:00:00 2001 From: Shyregena Date: Mon, 16 Oct 2023 15:22:15 +0300 Subject: [PATCH 18/29] =?UTF-8?q?=D0=AF=20=D0=BD=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BC=D0=B0=D1=8E=20=D0=B7=D0=B0=D1=87=D0=B5=D0=BC?= =?UTF-8?q?=20=D0=B5=D1=89=D1=91=20=D0=B8=20=D1=80=D0=B5=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D0=BD,=20=D0=BF=D1=80=D0=B8=D0=BD=D1=82=20=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D0=B2=D0=B5=20=D0=BD=D0=B5=20=D0=B0=D0=BD=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=82=D0=B0=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" | 1 + 1 file changed, 1 insertion(+) diff --git "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" index 20a900c8..d3efb4d3 100644 --- "a/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" +++ "b/Practice/tshyregena/\320\264\320\265\320\272\320\276\321\200\320\260\321\202\320\276\321\200.py" @@ -4,6 +4,7 @@ def fun_nuw(*args, **kwargs): res = fun(*args, **kwargs) print(res) print("="*10) + return res return fun_nuw From bd4f4fbb9763f880e6f9d7e5d37c6c5a1b0bf25c Mon Sep 17 00:00:00 2001 From: Shyregena Date: Mon, 16 Oct 2023 15:37:59 +0300 Subject: [PATCH 19/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "Practice/tshyregena/\321\202\320\260\320\261.py" | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git "a/Practice/tshyregena/\321\202\320\260\320\261.py" "b/Practice/tshyregena/\321\202\320\260\320\261.py" index 8eb70a3c..45369d80 100644 --- "a/Practice/tshyregena/\321\202\320\260\320\261.py" +++ "b/Practice/tshyregena/\321\202\320\260\320\261.py" @@ -1,9 +1,10 @@ with open("таб.txt", "r+", encoding="utf-8") as f: s = f.read() + print(s) p = input("Свернуть или развернуть символы табуляции: ").lower() k = "" if p == "свернуть": - k = s.replace('\t', ' ') - f.write(k) + k = s.replace(' ', '\t') else: - print(s) + k = s.replace('\t', ' ') + f.write(k) From 1edf356f81f558bb71622966c9a88c9a9738cde5 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Thu, 2 Nov 2023 16:11:11 +0300 Subject: [PATCH 20/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../8.4.1.py" | 13 ++++++++ .../8.4.2.py" | 4 +++ .../8.4.3.py" | 7 +++++ ...21\200\320\260\321\202\320\276\321\200.py" | 3 ++ ...0\260\321\202\320\276\321\200\320\260.txt" | 13 ++++++++ ...21\200\320\260\321\202\320\276\321\200.py" | 30 +++++++++++++++++++ ...21\202\320\265\320\272\321\201\321\202.py" | 21 +++++++++++++ ...0\270\320\265_\320\264\320\275\320\270.py" | 30 +++++++++++++++++++ 8 files changed, 121 insertions(+) create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.1.py" create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.2.py" create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.3.py" create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\264\320\273\321\217_\320\270\321\202\320\265\321\200\320\260\321\202\320\276\321\200\320\260.txt" create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\270\321\202\320\265\321\200\320\260\321\202\320\276\321\200.py" create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\272\320\276\320\275\321\202\320\265\320\272\321\201\321\202.py" create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_9/\321\200\320\260\320\261\320\276\321\207\320\270\320\265_\320\264\320\275\320\270.py" diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.1.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.1.py" new file mode 100644 index 00000000..afe9e4cc --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.1.py" @@ -0,0 +1,13 @@ +from collections.abc import Iterable + + +def flatten(items: Iterable): + for item in items: + if isinstance(item, Iterable): + yield from flatten(item) + else: + yield item + + +items1 = ([1, 2, 3], [4, 5], [6, 7]) +print(list(flatten(items1))) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.2.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.2.py" new file mode 100644 index 00000000..e56f62ca --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.2.py" @@ -0,0 +1,4 @@ +from itertools import filterfalse +lst = ['hello', 'i', 'write', 'cool', 'code'] +res = filterfalse(lambda x: len(x) < 5, lst) +print(list(res)) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.3.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.3.py" new file mode 100644 index 00000000..63185065 --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.3.py" @@ -0,0 +1,7 @@ +import itertools + +letters = "password" +perms = itertools.permutations(letters) + +for perm in perms: + print(perm) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" new file mode 100644 index 00000000..6ba5b83a --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" @@ -0,0 +1,3 @@ +with open("для_итератора.txt.", "r", encoding="utf-8") as file: + lines = [line for line in file] + print(lines) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\264\320\273\321\217_\320\270\321\202\320\265\321\200\320\260\321\202\320\276\321\200\320\260.txt" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\264\320\273\321\217_\320\270\321\202\320\265\321\200\320\260\321\202\320\276\321\200\320\260.txt" new file mode 100644 index 00000000..df2c9b55 --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\264\320\273\321\217_\320\270\321\202\320\265\321\200\320\260\321\202\320\276\321\200\320\260.txt" @@ -0,0 +1,13 @@ +Египетская летучая§ собака + +§ Описание +Египетская летучая собака имеет длину примерно 17 см. Шерсть имеет окрас бурого цвета, причём брюхо окрашено светлее. + +§ Распространение +Область распространения простирается от Египта и Аравийского полуострова до юга Турции и Кипра. + +§ Образ жизни +Животные живут большими колониями, активны ночью. Питаются плодами, при этом бо́льшую часть их рациона составляют незрелые плоды, повреждённые насекомыми или грибами. В поисках пищи животные за ночь пролетают до 40 км. Любимая пища — это инжир, затем апельсины, финики, бананы и молодые листья рожкового дерева. + +§ Размножение +Сезон размножения продолжается в природе с июня по сентябрь. Половая зрелость наступает в возрасте 9 месяцев. Период беременности длится приблизительно 115—120 дней. Самка, как правило, рожает одного детёныша в год, но иногда рождается и двойня. Приблизительно шесть недель самка носит детёныша на себе, не отпуская его. Позже она оставляет его висеть одного на скальных выступах, но продолжает кормить. \ No newline at end of file diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\270\321\202\320\265\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\270\321\202\320\265\321\200\320\260\321\202\320\276\321\200.py" new file mode 100644 index 00000000..2079cfa0 --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\270\321\202\320\265\321\200\320\260\321\202\320\276\321\200.py" @@ -0,0 +1,30 @@ +class Par: + def __init__(self, text, p): + self.text = text + self.p = p + self.i = 0 + + def __iter__(self): + return self + + def __next__(self): + res = "" + while self.i < len(self.text): + res1 = self.i + self.i += 1 + if self.text[res1] != self.p: + res += self.text[res1] + else: + return res + if res: + return res + raise StopIteration + + +t = Par("Египетская летучая §собака имеет длину §примерно 17 см", "§") +it = iter(t) +while True: + try: + print(next(it)) + except StopIteration: + break diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\272\320\276\320\275\321\202\320\265\320\272\321\201\321\202.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\272\320\276\320\275\321\202\320\265\320\272\321\201\321\202.py" new file mode 100644 index 00000000..36d6f926 --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\272\320\276\320\275\321\202\320\265\320\272\321\201\321\202.py" @@ -0,0 +1,21 @@ +import time + + +class MyMen: + def __enter__(self): + self.start_time = time.time() + print("Входим в менеджер контекста") + + def __exit__(self, exc_type, exc_val, exc_tb): + print("Выходим из менеджера контекста") + elapsed_time = time.time() - self.start_time + print(f"Время выполнения операции: {elapsed_time}") + + +with MyMen() as timer: + kidd = "Кошка мяукает. Собака лает. Птичка чирикает. Лягушка квакает." + a = dict(мяукает='говорит - мяу', лает='говорит - гав', чирикает='говорит - чирик-чирик', + квакает='говорит - ква-ква') + for key, value in a.items(): + kidd = kidd.replace(key, value) + print(kidd) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_9/\321\200\320\260\320\261\320\276\321\207\320\270\320\265_\320\264\320\275\320\270.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_9/\321\200\320\260\320\261\320\276\321\207\320\270\320\265_\320\264\320\275\320\270.py" new file mode 100644 index 00000000..c3e5fa8e --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_9/\321\200\320\260\320\261\320\276\321\207\320\270\320\265_\320\264\320\275\320\270.py" @@ -0,0 +1,30 @@ +import datetime as dt + + +def fun(weekday, time): + res = [] + i = 1 + t = time + w = weekday + while i <= t: + w3 = w.strftime("%w") + i += 1 + w = w + dt.timedelta(days=1) + if 0 < int(w3) <= 5: + res.append(w3) + else: + pass + return len(res) + + +y1 = int(input("Введите год первой даты в формате 'YYYY': ")) +m1 = int(input("Введите месяц первой даты в формате 'M': ")) +d1 = int(input("Введите день первой даты в формате 'D': ")) +weekday1 = dt.datetime(y1, m1, d1) +print(f'{weekday1} это {weekday1.strftime("%A")}') +y2 = int(input("Введите год первой даты в формате 'YYYY': ")) +m2 = int(input("Введите месяц первой даты в формате 'M': ")) +d2 = int(input("Введите день первой даты в формате 'D': ")) +weekday2 = dt.datetime(y2, m2, d2) +time3 = (weekday2 - weekday1).days +print(f"С начальной даты до конечной {fun(weekday1, time3)} рабочих дня") From 024ef1037ce385617ea297b94d39bea4ee92b42b Mon Sep 17 00:00:00 2001 From: Shyregena Date: Sat, 18 Nov 2023 14:37:57 +0300 Subject: [PATCH 21/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...276\321\207\320\270\320\265_\320\264\320\275\320\270.py" | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_9/\321\200\320\260\320\261\320\276\321\207\320\270\320\265_\320\264\320\275\320\270.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_9/\321\200\320\260\320\261\320\276\321\207\320\270\320\265_\320\264\320\275\320\270.py" index c3e5fa8e..9f76d602 100644 --- "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_9/\321\200\320\260\320\261\320\276\321\207\320\270\320\265_\320\264\320\275\320\270.py" +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_9/\321\200\320\260\320\261\320\276\321\207\320\270\320\265_\320\264\320\275\320\270.py" @@ -7,13 +7,11 @@ def fun(weekday, time): t = time w = weekday while i <= t: - w3 = w.strftime("%w") + w3 = w.weekday() i += 1 w = w + dt.timedelta(days=1) - if 0 < int(w3) <= 5: + if w3 < 5: res.append(w3) - else: - pass return len(res) From fd2920ea3f2939a1e7c33c084368b0c67e537afc Mon Sep 17 00:00:00 2001 From: Shyregena Date: Sat, 18 Nov 2023 14:40:51 +0300 Subject: [PATCH 22/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...21\202\321\200\320\270\321\206\320\260.py" | 30 +++++++++++++ ...21\202\321\200\320\270\321\206\320\260.py" | 44 ------------------- 2 files changed, 30 insertions(+), 44 deletions(-) create mode 100644 "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_5/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" delete mode 100644 "Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_5/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_5/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" new file mode 100644 index 00000000..8929fb04 --- /dev/null +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_5/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" @@ -0,0 +1,30 @@ + +def display(matrix1): + for r in matrix1: + print(r) + + +def display2(matrix3): + new_mat = [] + for k in range(len(matrix3[0])): + new_row = [] + for el in matrix3: + new_row.append(el[k]) + new_mat.append(new_row) + return new_mat + + +matrix2 = [[5, 4, 3, 8], + [6, 6, 7, 8], + [3, 9, 0, 6]] +display(matrix2) +new_mat1 = display2(matrix2) +p1 = int(input("Столбец с каким числом вы хотите удалить: ")) +i = 0 +while i < len(new_mat1): + if p1 in new_mat1[i]: + del new_mat1[i] + else: + i += 1 +new_mat2 = display2(new_mat1) +display(new_mat2) diff --git "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" "b/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" deleted file mode 100644 index 90865cae..00000000 --- "a/Practice/tshyregena/\320\274\320\260\321\202\321\200\320\270\321\206\320\260.py" +++ /dev/null @@ -1,44 +0,0 @@ - -def display(matrix1): - for r in matrix1: - print(r) - - -def display2(matrix3): - new_mat = [] - for k in range(len(matrix3[0])): - new_row = [] - for el in matrix3: - new_row.append(el[k]) - new_mat.append(new_row) - return new_mat - - -# matrix = [[5, 4, 3], -# [6, 6, 7], -# [3, 9, 0]] -# row1 = [matrix[0][0], matrix[1][0], matrix[2][0]] -# row2 = [matrix[0][1], matrix[1][1], matrix[2][1]] -# row3 = [matrix[0][2], matrix[1][2], matrix[2][2]] -# p = int(input("Какое число вы хотите удалить: ")) -# if p in row1: -# del [matrix[0][0], matrix[1][0], matrix[2][0]] -# if p in row2: -# del [matrix[0][1], matrix[1][1], matrix[2][1]] -# if p in row3: -# del [matrix[0][2], matrix[1][2], matrix[2][2]] -# matrix1 = matrix -# display(matrix1) -matrix2 = [[5, 4, 3, 8], - [6, 6, 7, 8], - [3, 9, 0, 6]] -new_mat1 = display2(matrix2) -print(new_mat1) -p1 = int(input("Какое число вы хотите удалить: ")) -i = 0 -while i < len(new_mat1): - if p1 in new_mat1[i]: - del new_mat1[i] - else: - i += 1 -display(new_mat1) From 75ba7cba7f43451566397e3e6f2111e8e6cf1976 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Sat, 18 Nov 2023 14:43:00 +0300 Subject: [PATCH 23/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\321\202\320\260\320\261.py" | 1 + 1 file changed, 1 insertion(+) rename "Practice/tshyregena/\321\202\320\260\320\261.py" => "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_5/\321\202\320\260\320\261.py" (90%) diff --git "a/Practice/tshyregena/\321\202\320\260\320\261.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_5/\321\202\320\260\320\261.py" similarity index 90% rename from "Practice/tshyregena/\321\202\320\260\320\261.py" rename to "Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_5/\321\202\320\260\320\261.py" index 45369d80..32655c3c 100644 --- "a/Practice/tshyregena/\321\202\320\260\320\261.py" +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_5/\321\202\320\260\320\261.py" @@ -7,4 +7,5 @@ k = s.replace(' ', '\t') else: k = s.replace('\t', ' ') +with open("таб.txt", "w") as f: f.write(k) From 88f92e4035b450cc69affc1c9d1816908cd8e783 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Sat, 18 Nov 2023 15:12:16 +0300 Subject: [PATCH 24/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...21\200\320\260\321\202\320\276\321\200.py" | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" index 6ba5b83a..cd08eef1 100644 --- "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" @@ -1,3 +1,20 @@ with open("для_итератора.txt.", "r", encoding="utf-8") as file: - lines = [line for line in file] - print(lines) + def gen(): + for line in file: + print(file.readline()) + yield line + + + r = gen() + for i in r: + print(i) + # print(next(r)) + # print(next(r)) + # print(next(r)) + + + + + + + From 5d8002241f9d4a77ead58e1b168b909188f398b8 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Tue, 21 Nov 2023 21:58:20 +0300 Subject: [PATCH 25/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../8.4.1.py" | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.1.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.1.py" index afe9e4cc..2eb8a42c 100644 --- "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.1.py" +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/8.4.1.py" @@ -1,13 +1,3 @@ -from collections.abc import Iterable +import itertools - -def flatten(items: Iterable): - for item in items: - if isinstance(item, Iterable): - yield from flatten(item) - else: - yield item - - -items1 = ([1, 2, 3], [4, 5], [6, 7]) -print(list(flatten(items1))) +print(list(itertools.chain([1, 2, 3], [4, 5], [6, 7]))) From 622a8dee05a43b5af3a71875341bc77709695354 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 22 Nov 2023 22:25:12 +0300 Subject: [PATCH 26/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...21\200\320\260\321\202\320\276\321\200.py" | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" index cd08eef1..64ed3e72 100644 --- "a/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" +++ "b/Practice/tshyregena/\320\273\320\265\320\272\321\206\320\270\321\217_8/\320\263\320\265\320\275\320\265\321\200\320\260\321\202\320\276\321\200.py" @@ -1,20 +1,14 @@ -with open("для_итератора.txt.", "r", encoding="utf-8") as file: - def gen(): + +def gen(name): + with open(name, "r", encoding="utf-8") as file: for line in file: print(file.readline()) yield line - r = gen() - for i in r: - print(i) - # print(next(r)) - # print(next(r)) - # print(next(r)) - - - - - - - +r = input("Введите имя файла: ") +for i in gen(r): + print(i) +# print(next(r)) +# print(next(r)) +# print(next(r)) From 1f1c62716ee2065b19c725293049b19f452ff67b Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 22 Nov 2023 22:55:52 +0300 Subject: [PATCH 27/29] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=BE=D0=B1?= =?UTF-8?q?=D1=83=D1=8E=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/tshyregena/pep8tasksh.py | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Practice/tshyregena/pep8tasksh.py diff --git a/Practice/tshyregena/pep8tasksh.py b/Practice/tshyregena/pep8tasksh.py new file mode 100644 index 00000000..36238417 --- /dev/null +++ b/Practice/tshyregena/pep8tasksh.py @@ -0,0 +1,69 @@ +import sys +import os +import hashlib +import ast +import argparse +from time import * + + +class shuffler: # Название класса написано не правильно, как вариант написать с большой буквы + + def __init__(self): # Отсутствует параметр map + self.map = {} + + def rename(self, dirname, output): # Может быть статическим методом + mp3s = [] # Не выровнено, поэтому не видит + for root, directories, files in os.walk(dirname): + for file in files: + if file[-3:] == '.mp3': + mp3s.append([root, file]) + for path, mp3 in mp3s: + hashname = self.generateName() + '.mp3' + self.map[hashname] = mp3 + os.rename(path + '/' + mp3), path + '/' + hashname)) # Возможно ошибка в названии mp3 + f = open(output, 'r') + f.write(str(self.map)) + + def restore(self, dirname, restore_path): # Не принимает filename + with open(filename, '+') as f: # проблема с выравниванием + self.map = ast.literal_eval(f.read()) + mp3s = [] + for root, directories, files in os.walk(dirname): + for file in files: + if file[-3:] == '.mp3': + mp3s.append({root, file}) + for path, hashname in mp3s: + os.rename(path + '/' + hashname, path + '/' + self.map[hashname])) + os.remove(restore_path) + + def generateName(self, seed=time()): # Название функции написано с ошибкой + return hashlib.md5(str(seed)).hexdigest() # проблема с выравниванием + + +def parse_arguments(): + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest='subcommand', help='subcommand help') + rename_parser = subparsers.add_parser('rename', help='rename help') + rename_parser.add_argument('dirname') + rename_parser.add_argument('-o', '--output', help='path to a file where restore map is stored') + restore_parser = subparsers.add_parser('restore', help="command_a help") + restore_parser.add_argument('dirname') + restore_parser.add_argument('restore_map') + args = parser.parse_args() + return args + +def main(): + args = parse_arguments() + Shuffler = shuffler() # ошибка в названии класса + if args.subcommand == 'rename': + if args.output: + Shuffler.rename(args.dirname, 'restore.info') + else: + Shuffler.rename(args.dirname, args.output) + elif args.subcommand == 'restore': + Shuffler.restore(args.dirname, args.restore_map) + else: + sys.exit() + + +main() From 30bbfbb84c864ae1d29ad4d1757e16bf54a2e432 Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 22 Nov 2023 23:17:52 +0300 Subject: [PATCH 28/29] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\262\320\276\320\267\320\262\321\200\320\260\321\202.py" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git "a/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" "b/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" index fcddc45f..ad74f1da 100644 --- "a/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" +++ "b/Practice/tshyregena/\320\262\320\276\320\267\320\262\321\200\320\260\321\202.py" @@ -1,11 +1,11 @@ def fun(lst): - res = [] + res = set() for element in lst: if element in res: return element else: - res.append(element) + res.add(element) -lst1 = [3, 9, 8, 3, 1, 8, 6] +lst1 = [4, 9, 8, 9, 1, 8, 6] print(fun(lst1)) From cdc9cd424cb83ca0858d26b06ace11d37090c24f Mon Sep 17 00:00:00 2001 From: Shyregena Date: Wed, 22 Nov 2023 23:18:10 +0300 Subject: [PATCH 29/29] =?UTF-8?q?=D0=9F=D0=BE=D0=BA=D0=B0=20=D0=B2=D1=80?= =?UTF-8?q?=D0=BE=D0=B4=D0=B5=20=D1=82=D0=B0=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/tshyregena/pep8tasksh.py | 41 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/Practice/tshyregena/pep8tasksh.py b/Practice/tshyregena/pep8tasksh.py index 36238417..d9605424 100644 --- a/Practice/tshyregena/pep8tasksh.py +++ b/Practice/tshyregena/pep8tasksh.py @@ -6,38 +6,38 @@ from time import * -class shuffler: # Название класса написано не правильно, как вариант написать с большой буквы +class Shuffler: - def __init__(self): # Отсутствует параметр map + def __init__(self, map): # Отсутствует параметр map self.map = {} def rename(self, dirname, output): # Может быть статическим методом - mp3s = [] # Не выровнено, поэтому не видит + mp3s = [] # Не выровнено, поэтому не видит for root, directories, files in os.walk(dirname): for file in files: if file[-3:] == '.mp3': mp3s.append([root, file]) for path, mp3 in mp3s: - hashname = self.generateName() + '.mp3' + hashname = self.generate_name() + '.mp3' self.map[hashname] = mp3 os.rename(path + '/' + mp3), path + '/' + hashname)) # Возможно ошибка в названии mp3 f = open(output, 'r') f.write(str(self.map)) - def restore(self, dirname, restore_path): # Не принимает filename - with open(filename, '+') as f: # проблема с выравниванием + def restore(self, dirname, restore_path, filename): # Не принимает filename + with open(filename, '+') as f: # проблема с выравниванием self.map = ast.literal_eval(f.read()) - mp3s = [] - for root, directories, files in os.walk(dirname): - for file in files: - if file[-3:] == '.mp3': - mp3s.append({root, file}) - for path, hashname in mp3s: - os.rename(path + '/' + hashname, path + '/' + self.map[hashname])) - os.remove(restore_path) + mp3s = [] + for root, directories, files in os.walk(dirname): + for file in files: + if file[-3:] == '.mp3': + mp3s.append({root, file}) + for path, hashname in mp3s: + os.rename(path + '/' + hashname, path + '/' + self.map[hashname])) + os.remove(restore_path) - def generateName(self, seed=time()): # Название функции написано с ошибкой - return hashlib.md5(str(seed)).hexdigest() # проблема с выравниванием + def generate_name(self, seed=time()): # Название функции написано с ошибкой + return hashlib.md5(str(seed)).hexdigest() # проблема с выравниванием def parse_arguments(): @@ -54,12 +54,11 @@ def parse_arguments(): def main(): args = parse_arguments() - Shuffler = shuffler() # ошибка в названии класса if args.subcommand == 'rename': - if args.output: - Shuffler.rename(args.dirname, 'restore.info') - else: - Shuffler.rename(args.dirname, args.output) + if args.output: + Shuffler.rename(args.dirname, 'restore.info') + else: + Shuffler.rename(args.dirname, args.output) elif args.subcommand == 'restore': Shuffler.restore(args.dirname, args.restore_map) else: