From 9635e3addd73d16483f0bc4a5f3aef9dc57cf44d Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Mon, 11 Sep 2023 16:47:07 +0300 Subject: [PATCH 01/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=204,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201,2,3,4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec4 task1.py | 17 +++++++++++++ Practice/mvolobuev/lec4 task2.py | 4 +++ Practice/mvolobuev/lec4 task3_2.py | 41 ++++++++++++++++++++++++++++++ Practice/mvolobuev/lec4 task4.py | 18 +++++++++++++ Practice/mvolobuev/lec4 task5.py | 27 ++++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 Practice/mvolobuev/lec4 task1.py create mode 100644 Practice/mvolobuev/lec4 task2.py create mode 100644 Practice/mvolobuev/lec4 task3_2.py create mode 100644 Practice/mvolobuev/lec4 task4.py create mode 100644 Practice/mvolobuev/lec4 task5.py diff --git a/Practice/mvolobuev/lec4 task1.py b/Practice/mvolobuev/lec4 task1.py new file mode 100644 index 00000000..9c56a7fe --- /dev/null +++ b/Practice/mvolobuev/lec4 task1.py @@ -0,0 +1,17 @@ +def sravnenie(a): + d1 = a // 3 * 3 + d2 = a // 5 * 5 + d3 = a // 15 * 15 + if d3 == a: print("FizzBuzz") + elif d1 == a: print("Fizz") + elif d2 == a: print("Buzz") + else: + print(a) + + +n = 1 +k = 101 +for i in range(n , k): + sravnenie(i) + + diff --git a/Practice/mvolobuev/lec4 task2.py b/Practice/mvolobuev/lec4 task2.py new file mode 100644 index 00000000..621dc0f6 --- /dev/null +++ b/Practice/mvolobuev/lec4 task2.py @@ -0,0 +1,4 @@ +n = str(input("Введите пятизначное число: ")) +for k in range(0, len(n)): + print(k+1, end='') + print(f" цифра равна: {n[k]}") diff --git a/Practice/mvolobuev/lec4 task3_2.py b/Practice/mvolobuev/lec4 task3_2.py new file mode 100644 index 00000000..c703025f --- /dev/null +++ b/Practice/mvolobuev/lec4 task3_2.py @@ -0,0 +1,41 @@ +def bukv(b, alfa): + nom = input(f"Введите порядковый номер для буквы: {b:} : ") + if nom.isdigit(): + nom = int(nom) + mon = alfavit[nom - 1] + bo1 = str(mon[1]) + if b == bo1: + print(f"Цифра соответствует букве : {bo1:}") + return + else: + print(f"Цифра соответствует букве {bo1:} 'попробйте еще раз") + bukv(b, alfa) + else: + print("Вместо цифры введена буква :") + bukv(b, alfa) + + +alfavit = [(1, "a"), (2,"b"),(3, "c"),(4, "d"),(5, "e"),(6, "f"),(7, "g"),(8, "h"),(9, "i"),(10, "j"),(11, "k"), + (12,"l"),(13,"m"),(14, "n"),(15, "o"),(16, "p"),(17, "q"),(18, "r"),(19, "s"),(20, "t"), + (21,"u"),(22, "v"),(23, "w"),(24, "x"),(25, "y"),(26, "z")] +print("Сегодня мы стараемся запомнить порядковый номер букв в алфавите, и набрать слово (stop)") +bs = alfavit[18] +bt = alfavit[19] +bo = alfavit[14] +bp = alfavit[15] +for k in range(0, 4): + if k == 0: + b = str(bs[1]) + bukv(b, alfavit) + else: + if k == 1: + b = str(bt[1]) + bukv(b, alfavit) + else: + if k == 2: + b = str(bo[1]) + bukv(b, alfavit) + else: + b = str(bp[1]) + bukv(b, alfavit) +print("Поздравляем, Вы ввели слово -stop-, цифры - 19-20-15-16") \ No newline at end of file diff --git a/Practice/mvolobuev/lec4 task4.py b/Practice/mvolobuev/lec4 task4.py new file mode 100644 index 00000000..b4693dac --- /dev/null +++ b/Practice/mvolobuev/lec4 task4.py @@ -0,0 +1,18 @@ +import random + + +def bukv(buk, stops): + j = 100 + for k in range(0, j): + zapros = input("Введите любое слово: ") + if zapros != stops: + i = random.randint(0, 2) + print(buk[i]) + else: + return + + +buk = ("Ты сам понял, что написал?", "Аргументируй", "И") +stops = ("хватит") +bukv(buk, stops) +print("Спасибо за беседу!") diff --git a/Practice/mvolobuev/lec4 task5.py b/Practice/mvolobuev/lec4 task5.py new file mode 100644 index 00000000..f456b1fb --- /dev/null +++ b/Practice/mvolobuev/lec4 task5.py @@ -0,0 +1,27 @@ +import random + + +def chisl(buk): + buk = int(buk) + zapros = input("Угадайте загадоное число от 1 до 10: ") + if zapros.isalpha():return + if int(zapros) == int(buk): + print("Угадали. ") + return + else: + zapros = int(zapros) + if zapros > 10: + print("Введено число больше 10") + chisl(buk) + else: + if zapros > buk: + print("Введеное число больше загадоного") + chisl(buk) + else: + print("Введеное число меньше загадоного") + chisl(buk) + + +i = random.randint(1, 10) +chisl(i) +print("Спасибо за игру!") From deb6c603abc863a125e765184c38d85f2ac9791c Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Tue, 12 Sep 2023 10:33:00 +0300 Subject: [PATCH 02/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=204,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=206,7,8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec4 task6.py | 13 +++++++++++++ Practice/mvolobuev/lec4 task7.py | 22 +++++++++++++++++++++ Practice/mvolobuev/lec4 task8.py | 33 ++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 Practice/mvolobuev/lec4 task6.py create mode 100644 Practice/mvolobuev/lec4 task7.py create mode 100644 Practice/mvolobuev/lec4 task8.py diff --git a/Practice/mvolobuev/lec4 task6.py b/Practice/mvolobuev/lec4 task6.py new file mode 100644 index 00000000..c4586098 --- /dev/null +++ b/Practice/mvolobuev/lec4 task6.py @@ -0,0 +1,13 @@ +def input_vvod(): + z1 = input("Введите первое число: ") + z2 = input("Введите второе число: ") + if z1 > z2: return z1 + if z1 <= z2: return z2 + +def print_vivod(maxi): + print(f"Наибольшее число: {maxi}") + + +print("Программа для определения наибольшего числа из двух введеных") +dx = input_vvod() +print_vivod(dx) diff --git a/Practice/mvolobuev/lec4 task7.py b/Practice/mvolobuev/lec4 task7.py new file mode 100644 index 00000000..c2b78905 --- /dev/null +++ b/Practice/mvolobuev/lec4 task7.py @@ -0,0 +1,22 @@ +def telo_dekor(a,b,c): + def podch(a,b,c): + print("================") + rex= fun_print(a,b,c) + print("================") + return rex + return podch (a,b,c) + + +def fun_print(a,b,c): + print(f"{a} + {b} = {c}") + + +def fun_sum(zn, zk): + zl = zn + zk + return zl + + +z1 = int(input("Введите первое число: ")) +z2 = int(input("Введите второе число: ")) +z = fun_sum(z1, z2) +telo_dekor(z1, z2, z) diff --git a/Practice/mvolobuev/lec4 task8.py b/Practice/mvolobuev/lec4 task8.py new file mode 100644 index 00000000..91ae4aca --- /dev/null +++ b/Practice/mvolobuev/lec4 task8.py @@ -0,0 +1,33 @@ +import random + + +def bukv(buky): + for k in range(0, 100): + zapros = input("Выберите одно из трех слов и введите его (Камень, Ножницы, Бумага), для выхода введите Хватит: ") + zapros = zapros.strip() + zapros = zapros.lower() + + if zapros == buky[3]: return + + if zapros not in buky: + print("Слово введено с ошибкой, введите слово заново") + else: + i = random.randint(0, 2) + if zapros == buky[i]: + print(f"Мы выбрали тоже: {zapros}") + else: + if i == 0: + if zapros == buky[1]: print (f"{buky[i]} Вы проиграли") + if zapros == buky[2]: print(f"{buky[i]} Вы выиграли") + if i == 1: + if zapros == buky[0]: print (f"{buky[i]} Вы выиграли") + if zapros == buky[2]: print(f"{buk[i]} Вы проиграли") + if i == 2: + if zapros == buky[0]:print(f"{buky[i]} Вы проиграли") + if zapros == buky[1]: print(f"{buky[i]} Вы выиграли") + + + +buk = ["камень", "ножницы", "бумага", "хватит"] +bukv(buk) +print("Спасибо за игру!") \ No newline at end of file From fb9e846582df7f973cf3929d797a9e63d9e9e323 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Tue, 12 Sep 2023 14:39:10 +0300 Subject: [PATCH 03/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201,2,3,4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task1.py | 9 +++++++++ Practice/mvolobuev/lec5 task2.py | 17 +++++++++++++++++ Practice/mvolobuev/lec5 task3.py | 10 ++++++++++ Practice/mvolobuev/lec5 task4.py | 17 +++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 Practice/mvolobuev/lec5 task1.py create mode 100644 Practice/mvolobuev/lec5 task2.py create mode 100644 Practice/mvolobuev/lec5 task3.py create mode 100644 Practice/mvolobuev/lec5 task4.py diff --git a/Practice/mvolobuev/lec5 task1.py b/Practice/mvolobuev/lec5 task1.py new file mode 100644 index 00000000..201e53a8 --- /dev/null +++ b/Practice/mvolobuev/lec5 task1.py @@ -0,0 +1,9 @@ +arg = [0, 3, 24, 2, 3, 7] +print(arg) +for i in range(0, len(arg)-1): + for k in range(i+1, len(arg)): + if int(arg[k]) < int(arg[i]): + ar = arg[i] + arg[i] = arg[k] + arg[k] = ar +print(arg) \ No newline at end of file diff --git a/Practice/mvolobuev/lec5 task2.py b/Practice/mvolobuev/lec5 task2.py new file mode 100644 index 00000000..b6828fb6 --- /dev/null +++ b/Practice/mvolobuev/lec5 task2.py @@ -0,0 +1,17 @@ +def fun_povtor(st): + j1 = len(st) + j2 = len(st) + for i in range(0, len(st) - 1): + for k in range(i + 1, len(st)): + if int(st[k]) == int(st[i]): + if k-i < j2: + j1 = st[k] + j2 = k-i + print(f"Первый повторившийся символ: {j1}") + + + + +arg = [2, 3, 4, 5, 3, 2] +print(arg) +fun_povtor(arg) diff --git a/Practice/mvolobuev/lec5 task3.py b/Practice/mvolobuev/lec5 task3.py new file mode 100644 index 00000000..5d0876c6 --- /dev/null +++ b/Practice/mvolobuev/lec5 task3.py @@ -0,0 +1,10 @@ +import random +from string import Template + +t = Template('Казнить$lang нельзя$lang1 помиловать.') +i = random.randint(0, 1) +if i == 0: + p = t.substitute(lang=',', lang1='') +else: + p = t.substitute(lang='', lang1=',') +print(p) diff --git a/Practice/mvolobuev/lec5 task4.py b/Practice/mvolobuev/lec5 task4.py new file mode 100644 index 00000000..391d8378 --- /dev/null +++ b/Practice/mvolobuev/lec5 task4.py @@ -0,0 +1,17 @@ +art = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] +for i in range(0, 4): + print(art[i]) + +k = int(input("Введите цифру от 1 до 16, столбец которой нужно удалить: ")) +for i in range(0, 4): + for j in range(0, 4): + g = art[i] + if int(g[j]) == k: + st = j + +for i in range(0, 4): + g = art[i] + del(g[st]) + +for i in range(0, 4): + print(art[i]) \ No newline at end of file From 5633d564958cbdd9e1e8fddf8d2e1b691477a6ec Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Wed, 13 Sep 2023 14:08:11 +0300 Subject: [PATCH 04/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201,2,3,4.=20?= =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec4 task1.py | 22 +++++++------- Practice/mvolobuev/lec4 task2.py | 5 ++-- Practice/mvolobuev/lec4 task3_2.py | 17 +++++++---- Practice/mvolobuev/lec4 task4.py | 3 +- Practice/mvolobuev/lec4 task5.py | 48 +++++++++++++++++++----------- Practice/mvolobuev/lec4 task6.py | 22 ++++++++++---- Practice/mvolobuev/lec4 task7.py | 12 ++++---- Practice/mvolobuev/lec4 task8.py | 24 ++++++++++----- 8 files changed, 93 insertions(+), 60 deletions(-) diff --git a/Practice/mvolobuev/lec4 task1.py b/Practice/mvolobuev/lec4 task1.py index 9c56a7fe..31c04afe 100644 --- a/Practice/mvolobuev/lec4 task1.py +++ b/Practice/mvolobuev/lec4 task1.py @@ -1,17 +1,15 @@ def sravnenie(a): - d1 = a // 3 * 3 - d2 = a // 5 * 5 - d3 = a // 15 * 15 - if d3 == a: print("FizzBuzz") - elif d1 == a: print("Fizz") - elif d2 == a: print("Buzz") + if a % 3 == 0: + print("FizzBuzz") else: - print(a) + if a % 5 == 0: + print("Fizz") + else: + if a % 15 == 0: + print("Buzz") + else: + print(a) -n = 1 -k = 101 -for i in range(n , k): +for i in range(1, 101): sravnenie(i) - - diff --git a/Practice/mvolobuev/lec4 task2.py b/Practice/mvolobuev/lec4 task2.py index 621dc0f6..aaaa1207 100644 --- a/Practice/mvolobuev/lec4 task2.py +++ b/Practice/mvolobuev/lec4 task2.py @@ -1,4 +1,3 @@ -n = str(input("Введите пятизначное число: ")) +n = input("Введите пятизначное число: ") for k in range(0, len(n)): - print(k+1, end='') - print(f" цифра равна: {n[k]}") + print(f"{k+1} цифра равна: {n[k]}") diff --git a/Practice/mvolobuev/lec4 task3_2.py b/Practice/mvolobuev/lec4 task3_2.py index c703025f..f81b068b 100644 --- a/Practice/mvolobuev/lec4 task3_2.py +++ b/Practice/mvolobuev/lec4 task3_2.py @@ -6,7 +6,7 @@ def bukv(b, alfa): bo1 = str(mon[1]) if b == bo1: print(f"Цифра соответствует букве : {bo1:}") - return + return nom else: print(f"Цифра соответствует букве {bo1:} 'попробйте еще раз") bukv(b, alfa) @@ -23,19 +23,24 @@ def bukv(b, alfa): bt = alfavit[19] bo = alfavit[14] bp = alfavit[15] +s = "" for k in range(0, 4): if k == 0: b = str(bs[1]) - bukv(b, alfavit) + s1 = bukv(b, alfavit) + s = s + str(s1) +" " else: if k == 1: b = str(bt[1]) - bukv(b, alfavit) + s1 = bukv(b, alfavit) + s = s + str(s1) +" " else: if k == 2: b = str(bo[1]) - bukv(b, alfavit) + s1 = bukv(b, alfavit) + s = s + str(s1) +" " else: b = str(bp[1]) - bukv(b, alfavit) -print("Поздравляем, Вы ввели слово -stop-, цифры - 19-20-15-16") \ No newline at end of file + s1 = bukv(b, alfavit) + s = s + str(s1) +" " +print(f"Поздравляем, Вы ввели слово -stop-, цифры - {s}") \ No newline at end of file diff --git a/Practice/mvolobuev/lec4 task4.py b/Practice/mvolobuev/lec4 task4.py index b4693dac..64b59b4d 100644 --- a/Practice/mvolobuev/lec4 task4.py +++ b/Practice/mvolobuev/lec4 task4.py @@ -6,8 +6,7 @@ def bukv(buk, stops): for k in range(0, j): zapros = input("Введите любое слово: ") if zapros != stops: - i = random.randint(0, 2) - print(buk[i]) + print(random.choice(buk)) else: return diff --git a/Practice/mvolobuev/lec4 task5.py b/Practice/mvolobuev/lec4 task5.py index f456b1fb..ea579b58 100644 --- a/Practice/mvolobuev/lec4 task5.py +++ b/Practice/mvolobuev/lec4 task5.py @@ -1,27 +1,39 @@ import random -def chisl(buk): +def chisl(buk, a, b): + a = int(a) + b = int(b) buk = int(buk) - zapros = input("Угадайте загадоное число от 1 до 10: ") - if zapros.isalpha():return - if int(zapros) == int(buk): - print("Угадали. ") - return - else: - zapros = int(zapros) - if zapros > 10: - print("Введено число больше 10") - chisl(buk) + zapros = input("Угадайте загадоное число в заданном дипазоне: ") + if zapros.isdigit(): + print(f"{zapros}") + if int(zapros) == int(buk): + print("Угадали. ") + return zapros else: - if zapros > buk: - print("Введеное число больше загадоного") - chisl(buk) + zapros = int(zapros) + if zapros > b: + print("Введено число больше верхнего диапазона") + chisl(buk, a, b) else: - print("Введеное число меньше загадоного") - chisl(buk) + if zapros < a: + print("Введено число меньше нижнего диапазона") + chisl(buk, a, b) + else: + if zapros > buk: + print("Введеное число больше загадоного") + chisl(buk, a, b) + else: + print("Введеное число меньше загадоного") + chisl(buk, a, b) + else: + print("Введена точка") + return zapros -i = random.randint(1, 10) -chisl(i) +a = int(input("Введите цифру, начало диапазона : ")) +b = int(input("Введите цифру, конец диапазона : ")) +i = random.randint(a, b) +chisl(i, a, b) print("Спасибо за игру!") diff --git a/Practice/mvolobuev/lec4 task6.py b/Practice/mvolobuev/lec4 task6.py index c4586098..94fd1f83 100644 --- a/Practice/mvolobuev/lec4 task6.py +++ b/Practice/mvolobuev/lec4 task6.py @@ -1,13 +1,23 @@ -def input_vvod(): - z1 = input("Введите первое число: ") - z2 = input("Введите второе число: ") - if z1 > z2: return z1 - if z1 <= z2: return z2 +def input_vvod(z1, z2): + if z1 > z2: + return z1 + else: + return z2 def print_vivod(maxi): print(f"Наибольшее число: {maxi}") +def print_viv(z1, z2): + if z1 > z2: + print(f"Наибольшее число: {z1}") + else: + print(f"Наибольшее число: {z2}") + + print("Программа для определения наибольшего числа из двух введеных") -dx = input_vvod() +z1 = input("Введите первое число: ") +z2 = input("Введите второе число: ") +dx = input_vvod(z1, z2) print_vivod(dx) +print_viv(z1, z2) \ No newline at end of file diff --git a/Practice/mvolobuev/lec4 task7.py b/Practice/mvolobuev/lec4 task7.py index c2b78905..7cc9544b 100644 --- a/Practice/mvolobuev/lec4 task7.py +++ b/Practice/mvolobuev/lec4 task7.py @@ -1,12 +1,13 @@ -def telo_dekor(a,b,c): - def podch(a,b,c): +def telo_dekor(fun): + def podch(*args, **kwargs): print("================") - rex= fun_print(a,b,c) + rex= fun(*args, **kwargs) print("================") return rex - return podch (a,b,c) + return podch +@telo_dekor def fun_print(a,b,c): print(f"{a} + {b} = {c}") @@ -19,4 +20,5 @@ def fun_sum(zn, zk): z1 = int(input("Введите первое число: ")) z2 = int(input("Введите второе число: ")) z = fun_sum(z1, z2) -telo_dekor(z1, z2, z) +fun_print(z1,z2,z) +#telo_dekor(z1, z2, z) diff --git a/Practice/mvolobuev/lec4 task8.py b/Practice/mvolobuev/lec4 task8.py index 91ae4aca..d3a2d6c5 100644 --- a/Practice/mvolobuev/lec4 task8.py +++ b/Practice/mvolobuev/lec4 task8.py @@ -17,14 +17,22 @@ def bukv(buky): print(f"Мы выбрали тоже: {zapros}") else: if i == 0: - if zapros == buky[1]: print (f"{buky[i]} Вы проиграли") - if zapros == buky[2]: print(f"{buky[i]} Вы выиграли") - if i == 1: - if zapros == buky[0]: print (f"{buky[i]} Вы выиграли") - if zapros == buky[2]: print(f"{buk[i]} Вы проиграли") - if i == 2: - if zapros == buky[0]:print(f"{buky[i]} Вы проиграли") - if zapros == buky[1]: print(f"{buky[i]} Вы выиграли") + if zapros == buky[1]: + print (f"{buky[i]} Вы проиграли") + else: + print(f"{buky[i]} Вы выиграли") + else: + if i == 1: + if zapros == buky[0]: + print (f"{buky[i]} Вы выиграли") + else: + print(f"{buk[i]} Вы проиграли") + else: + if i == 2: + if zapros == buky[0]: + print(f"{buky[i]} Вы проиграли") + else: + print(f"{buky[i]} Вы выиграли") From 5098e94ed70daa4e264f01a7a33a05dc4bdc9c2b Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Thu, 14 Sep 2023 08:44:35 +0300 Subject: [PATCH 05/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201,2,3,4.=20?= =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B.=20arg[i],?= =?UTF-8?q?=20arg[k]=20=3D=20arg[k],=20arg[i]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task1.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Practice/mvolobuev/lec5 task1.py b/Practice/mvolobuev/lec5 task1.py index 201e53a8..f0fe1d9f 100644 --- a/Practice/mvolobuev/lec5 task1.py +++ b/Practice/mvolobuev/lec5 task1.py @@ -3,7 +3,5 @@ for i in range(0, len(arg)-1): for k in range(i+1, len(arg)): if int(arg[k]) < int(arg[i]): - ar = arg[i] - arg[i] = arg[k] - arg[k] = ar + arg[i], arg[k] = arg[k], arg[i] print(arg) \ No newline at end of file From d9208e3971ffa50eed721c0e363f3b46c6e2177f Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Fri, 15 Sep 2023 14:51:04 +0300 Subject: [PATCH 06/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201,2,3,4.=20?= =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec4 task1.py | 4 ++-- Practice/mvolobuev/lec4 task5.py | 7 ++----- Practice/mvolobuev/lec4 task8.py | 2 +- Practice/mvolobuev/lec5 task1.py | 10 +++++++--- Practice/mvolobuev/lec5 task4.py | 17 +++++++++++------ 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Practice/mvolobuev/lec4 task1.py b/Practice/mvolobuev/lec4 task1.py index 31c04afe..ca08fed2 100644 --- a/Practice/mvolobuev/lec4 task1.py +++ b/Practice/mvolobuev/lec4 task1.py @@ -1,11 +1,11 @@ def sravnenie(a): - if a % 3 == 0: + if a % 15 == 0: print("FizzBuzz") else: if a % 5 == 0: print("Fizz") else: - if a % 15 == 0: + if a % 3 == 0: print("Buzz") else: print(a) diff --git a/Practice/mvolobuev/lec4 task5.py b/Practice/mvolobuev/lec4 task5.py index ea579b58..508b9ddd 100644 --- a/Practice/mvolobuev/lec4 task5.py +++ b/Practice/mvolobuev/lec4 task5.py @@ -8,25 +8,22 @@ def chisl(buk, a, b): zapros = input("Угадайте загадоное число в заданном дипазоне: ") if zapros.isdigit(): print(f"{zapros}") - if int(zapros) == int(buk): + if int(zapros) == buk: print("Угадали. ") return zapros else: zapros = int(zapros) if zapros > b: print("Введено число больше верхнего диапазона") - chisl(buk, a, b) else: if zapros < a: print("Введено число меньше нижнего диапазона") - chisl(buk, a, b) else: if zapros > buk: print("Введеное число больше загадоного") - chisl(buk, a, b) else: print("Введеное число меньше загадоного") - chisl(buk, a, b) + chisl(buk, a, b) else: print("Введена точка") return zapros diff --git a/Practice/mvolobuev/lec4 task8.py b/Practice/mvolobuev/lec4 task8.py index d3a2d6c5..2eb5158a 100644 --- a/Practice/mvolobuev/lec4 task8.py +++ b/Practice/mvolobuev/lec4 task8.py @@ -38,4 +38,4 @@ def bukv(buky): buk = ["камень", "ножницы", "бумага", "хватит"] bukv(buk) -print("Спасибо за игру!") \ No newline at end of file +print("Спасибо за игру!") diff --git a/Practice/mvolobuev/lec5 task1.py b/Practice/mvolobuev/lec5 task1.py index f0fe1d9f..923f94b7 100644 --- a/Practice/mvolobuev/lec5 task1.py +++ b/Practice/mvolobuev/lec5 task1.py @@ -1,7 +1,11 @@ arg = [0, 3, 24, 2, 3, 7] print(arg) for i in range(0, len(arg)-1): + n = i for k in range(i+1, len(arg)): - if int(arg[k]) < int(arg[i]): - arg[i], arg[k] = arg[k], arg[i] -print(arg) \ No newline at end of file + if arg[k] < arg[i]: + if arg[k] < arg[n]: + n = k + arg[i], arg[n] = arg[n], arg[i] +print(arg) + diff --git a/Practice/mvolobuev/lec5 task4.py b/Practice/mvolobuev/lec5 task4.py index 391d8378..cfc087f3 100644 --- a/Practice/mvolobuev/lec5 task4.py +++ b/Practice/mvolobuev/lec5 task4.py @@ -1,17 +1,22 @@ -art = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] +art = [[1, 2, 3, 4], [5, 6, 2, 8], [9, 10, 11, 12], [13, 14, 15, 16]] +st = [-1, -1, -1, -1] for i in range(0, 4): print(art[i]) k = int(input("Введите цифру от 1 до 16, столбец которой нужно удалить: ")) +i1 = 0 for i in range(0, 4): for j in range(0, 4): g = art[i] if int(g[j]) == k: - st = j + st[i1] = j + i1 +=1 -for i in range(0, 4): - g = art[i] - del(g[st]) +for j1 in range(0, i1): + s1 = st[j1] + for i in range(0, 4): + g = art[i] + del(g[s1]) for i in range(0, 4): - print(art[i]) \ No newline at end of file + print(art[i]) From b19f092931dfed6288e6fcb553c979afb936113c Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Fri, 15 Sep 2023 15:44:46 +0300 Subject: [PATCH 07/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201,2,3,4.=20?= =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task3.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Practice/mvolobuev/lec5 task3.py b/Practice/mvolobuev/lec5 task3.py index 5d0876c6..d5998a17 100644 --- a/Practice/mvolobuev/lec5 task3.py +++ b/Practice/mvolobuev/lec5 task3.py @@ -1,10 +1,16 @@ -import random -from string import Template +def zam(t, dik1): + t2 = list('') + n = len(t) + k = t.count('дождь') + for i in range(0, k): + d = t.find('дождь') + t2 = t[0:d] + dik1['дождь'] + t[d+5:n] + t = t2 + return t -t = Template('Казнить$lang нельзя$lang1 помиловать.') -i = random.randint(0, 1) -if i == 0: - p = t.substitute(lang=',', lang1='') -else: - p = t.substitute(lang='', lang1=',') -print(p) + +t = ('Вчера был дождь, и завтра будет дождь.') +dik = {'Вчера': 'Завтра', 'дождь': 'ветер'} +print(t) +t = zam(t, dik) +print(t) From 40e3da6c1df6c1c9c9b6890802fc84a6bb5e1930 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Mon, 18 Sep 2023 09:31:45 +0300 Subject: [PATCH 08/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201,3,4.=20=D0=98?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task1.py | 1 - Practice/mvolobuev/lec5 task3.py | 3 +-- Practice/mvolobuev/lec5 task4.py | 12 ++++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Practice/mvolobuev/lec5 task1.py b/Practice/mvolobuev/lec5 task1.py index 923f94b7..790dfb85 100644 --- a/Practice/mvolobuev/lec5 task1.py +++ b/Practice/mvolobuev/lec5 task1.py @@ -8,4 +8,3 @@ n = k arg[i], arg[n] = arg[n], arg[i] print(arg) - diff --git a/Practice/mvolobuev/lec5 task3.py b/Practice/mvolobuev/lec5 task3.py index d5998a17..0b1c9406 100644 --- a/Practice/mvolobuev/lec5 task3.py +++ b/Practice/mvolobuev/lec5 task3.py @@ -1,5 +1,4 @@ def zam(t, dik1): - t2 = list('') n = len(t) k = t.count('дождь') for i in range(0, k): @@ -9,7 +8,7 @@ def zam(t, dik1): return t -t = ('Вчера был дождь, и завтра будет дождь.') +t = 'Вчера был дождь, и завтра будет дождь.' dik = {'Вчера': 'Завтра', 'дождь': 'ветер'} print(t) t = zam(t, dik) diff --git a/Practice/mvolobuev/lec5 task4.py b/Practice/mvolobuev/lec5 task4.py index cfc087f3..6637f737 100644 --- a/Practice/mvolobuev/lec5 task4.py +++ b/Practice/mvolobuev/lec5 task4.py @@ -5,18 +5,18 @@ k = int(input("Введите цифру от 1 до 16, столбец которой нужно удалить: ")) i1 = 0 -for i in range(0, 4): - for j in range(0, 4): +for i in range(0, len(art)): + for j in range(0, len(art[0])): g = art[i] - if int(g[j]) == k: + if g[j] == k: st[i1] = j i1 +=1 for j1 in range(0, i1): s1 = st[j1] - for i in range(0, 4): + for i in range(0, len(art)): g = art[i] - del(g[s1]) + del(g[s1-j1]) -for i in range(0, 4): +for i in range(0, len(art)): print(art[i]) From 87ad4231dece584c93ab5d659afd3eaf495f73a2 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Wed, 27 Sep 2023 08:41:53 +0300 Subject: [PATCH 09/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201.=20=D0=98?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B2=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task1.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Practice/mvolobuev/lec5 task1.py b/Practice/mvolobuev/lec5 task1.py index 790dfb85..b7f02219 100644 --- a/Practice/mvolobuev/lec5 task1.py +++ b/Practice/mvolobuev/lec5 task1.py @@ -2,9 +2,8 @@ print(arg) for i in range(0, len(arg)-1): n = i - for k in range(i+1, len(arg)): - if arg[k] < arg[i]: - if arg[k] < arg[n]: - n = k + for k in range(i + 1, len(arg)): + if arg[k] < arg[n]: + n = k arg[i], arg[n] = arg[n], arg[i] print(arg) From d68983943f47aa50318222a4d4fab991ba06ba18 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Wed, 27 Sep 2023 14:51:31 +0300 Subject: [PATCH 10/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec4 task3_2.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Practice/mvolobuev/lec4 task3_2.py b/Practice/mvolobuev/lec4 task3_2.py index f81b068b..bf4fdc48 100644 --- a/Practice/mvolobuev/lec4 task3_2.py +++ b/Practice/mvolobuev/lec4 task3_2.py @@ -15,6 +15,10 @@ def bukv(b, alfa): bukv(b, alfa) +def buk_v(b, s, s1, alfavit): + s1 = bukv(b, alfavit) + s = s + str(s1) + " " + alfavit = [(1, "a"), (2,"b"),(3, "c"),(4, "d"),(5, "e"),(6, "f"),(7, "g"),(8, "h"),(9, "i"),(10, "j"),(11, "k"), (12,"l"),(13,"m"),(14, "n"),(15, "o"),(16, "p"),(17, "q"),(18, "r"),(19, "s"),(20, "t"), (21,"u"),(22, "v"),(23, "w"),(24, "x"),(25, "y"),(26, "z")] @@ -27,18 +31,15 @@ def bukv(b, alfa): for k in range(0, 4): if k == 0: b = str(bs[1]) - s1 = bukv(b, alfavit) - s = s + str(s1) +" " + buk_v(b, s, s1, alfavit) else: if k == 1: b = str(bt[1]) - s1 = bukv(b, alfavit) - s = s + str(s1) +" " + buk_v(b, s, s1, alfavit) else: if k == 2: b = str(bo[1]) - s1 = bukv(b, alfavit) - s = s + str(s1) +" " + buk_v(b, s, s1, alfavit) else: b = str(bp[1]) s1 = bukv(b, alfavit) From 4397ed45562aec48bb44e0303651492f73bacb6c Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Wed, 27 Sep 2023 14:52:21 +0300 Subject: [PATCH 11/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task5.py | 4 ++++ Practice/mvolobuev/lec5 task5_1.py | 12 ++++++++++++ Practice/mvolobuev/lec5 task5_2.py | 11 +++++++++++ 3 files changed, 27 insertions(+) create mode 100644 Practice/mvolobuev/lec5 task5.py create mode 100644 Practice/mvolobuev/lec5 task5_1.py create mode 100644 Practice/mvolobuev/lec5 task5_2.py diff --git a/Practice/mvolobuev/lec5 task5.py b/Practice/mvolobuev/lec5 task5.py new file mode 100644 index 00000000..277f4eee --- /dev/null +++ b/Practice/mvolobuev/lec5 task5.py @@ -0,0 +1,4 @@ +with open("Piton.txt","w",encoding= "utf-8") as f: + f.write("\tЭнтони Шоу — заядлый питонист, участник Python Software Foundation.") +# f.write("\tСтрасть Энтони — разбираться в сложных системах,\n") +# f.write("упрощать их и обучать других людей.") diff --git a/Practice/mvolobuev/lec5 task5_1.py b/Practice/mvolobuev/lec5 task5_1.py new file mode 100644 index 00000000..5b100a5f --- /dev/null +++ b/Practice/mvolobuev/lec5 task5_1.py @@ -0,0 +1,12 @@ +# Замена Tab на пробелы +h = int(input("Введите количество пробелов вместо Tab: ")) +i = 0 +slist = [] +with open("Piton.txt", "r", encoding="utf-8") as f1: + for s in f1: + slist.append(s.expandtabs(tabsize=h)) + i += 1 + print(slist) + +with open("Piton.txt","w",encoding= "utf-8") as f: + f.write(slist[i-1]) diff --git a/Practice/mvolobuev/lec5 task5_2.py b/Practice/mvolobuev/lec5 task5_2.py new file mode 100644 index 00000000..9d135341 --- /dev/null +++ b/Practice/mvolobuev/lec5 task5_2.py @@ -0,0 +1,11 @@ +# Замена проберов на Tab +i = 0 +slist = [] +with open("Piton.txt", "r", encoding="utf-8") as f1: + for s in f1: + slist = "\t" + s.lstrip() + i += 1 + print(slist) + +with open("Piton.txt","w",encoding= "utf-8") as f: + f.write(slist) \ No newline at end of file From e71624f72df55b22643fef967aaa14a3ac4fb510 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Thu, 28 Sep 2023 10:54:10 +0300 Subject: [PATCH 12/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task4.py | 10 ++++++---- Practice/mvolobuev/lec5 task5.py | 6 +++--- Practice/mvolobuev/lec5 task5_1.py | 4 ++-- Practice/mvolobuev/lec5 task5_2.py | 9 ++++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Practice/mvolobuev/lec5 task4.py b/Practice/mvolobuev/lec5 task4.py index 6637f737..da11f757 100644 --- a/Practice/mvolobuev/lec5 task4.py +++ b/Practice/mvolobuev/lec5 task4.py @@ -1,4 +1,4 @@ -art = [[1, 2, 3, 4], [5, 6, 2, 8], [9, 10, 11, 12], [13, 14, 15, 16]] +art = [[1, 2, 3, 4], [5, 2, 2, 8], [9, 10, 11, 12], [13, 14, 15, 16]] st = [-1, -1, -1, -1] for i in range(0, 4): print(art[i]) @@ -10,13 +10,15 @@ g = art[i] if g[j] == k: st[i1] = j - i1 +=1 + if st[i1] == st[i1-1]: + st[i1] = -1 + else: + i1 +=1 for j1 in range(0, i1): s1 = st[j1] for i in range(0, len(art)): g = art[i] del(g[s1-j1]) - -for i in range(0, len(art)): +for i in range(0, len(art) - 1): print(art[i]) diff --git a/Practice/mvolobuev/lec5 task5.py b/Practice/mvolobuev/lec5 task5.py index 277f4eee..84c7fbec 100644 --- a/Practice/mvolobuev/lec5 task5.py +++ b/Practice/mvolobuev/lec5 task5.py @@ -1,4 +1,4 @@ with open("Piton.txt","w",encoding= "utf-8") as f: - f.write("\tЭнтони Шоу — заядлый питонист, участник Python Software Foundation.") -# f.write("\tСтрасть Энтони — разбираться в сложных системах,\n") -# f.write("упрощать их и обучать других людей.") + f.write("\tЭнтони Шоу — заядлый питонист, участник Python Software Foundation.,\n") + f.write("\tСтрасть Энтони — разбираться в сложных системах,\n") + f.write("упрощать их и обучать других людей.") diff --git a/Practice/mvolobuev/lec5 task5_1.py b/Practice/mvolobuev/lec5 task5_1.py index 5b100a5f..0afe6155 100644 --- a/Practice/mvolobuev/lec5 task5_1.py +++ b/Practice/mvolobuev/lec5 task5_1.py @@ -1,7 +1,6 @@ # Замена Tab на пробелы h = int(input("Введите количество пробелов вместо Tab: ")) i = 0 -slist = [] with open("Piton.txt", "r", encoding="utf-8") as f1: for s in f1: slist.append(s.expandtabs(tabsize=h)) @@ -9,4 +8,5 @@ print(slist) with open("Piton.txt","w",encoding= "utf-8") as f: - f.write(slist[i-1]) + for i1 in range(0, i): + f.write(slist[i1]) diff --git a/Practice/mvolobuev/lec5 task5_2.py b/Practice/mvolobuev/lec5 task5_2.py index 9d135341..7d8bafb4 100644 --- a/Practice/mvolobuev/lec5 task5_2.py +++ b/Practice/mvolobuev/lec5 task5_2.py @@ -1,11 +1,14 @@ # Замена проберов на Tab i = 0 -slist = [] +s2 = "" with open("Piton.txt", "r", encoding="utf-8") as f1: + slist = "" for s in f1: - slist = "\t" + s.lstrip() + s1 = " " + s.strip() + slist = slist + s2 + s1.replace(" ", "\t", 1) + s2= "\n" i += 1 print(slist) with open("Piton.txt","w",encoding= "utf-8") as f: - f.write(slist) \ No newline at end of file + f.write(slist) From be0f1ab032e88a61694a6056577f95008f2e07fc Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Fri, 29 Sep 2023 09:45:17 +0300 Subject: [PATCH 13/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task4.py | 11 ++++++----- Practice/mvolobuev/lec5 task5_1.py | 4 +--- Practice/mvolobuev/lec5 task5_2.py | 3 --- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Practice/mvolobuev/lec5 task4.py b/Practice/mvolobuev/lec5 task4.py index da11f757..2a3f3153 100644 --- a/Practice/mvolobuev/lec5 task4.py +++ b/Practice/mvolobuev/lec5 task4.py @@ -1,4 +1,4 @@ -art = [[1, 2, 3, 4], [5, 2, 2, 8], [9, 10, 11, 12], [13, 14, 15, 16]] +art = [[1, 2, 3, 4], [5, 6, 2, 8], [9, 2, 11, 12], [13, 14, 15, 16]] st = [-1, -1, -1, -1] for i in range(0, 4): print(art[i]) @@ -10,15 +10,16 @@ g = art[i] if g[j] == k: st[i1] = j - if st[i1] == st[i1-1]: + if j == st[i1-1] or j == st[i1-2] or j == st[i1-3]: st[i1] = -1 else: - i1 +=1 + i1 += 1 for j1 in range(0, i1): s1 = st[j1] for i in range(0, len(art)): g = art[i] del(g[s1-j1]) -for i in range(0, len(art) - 1): - print(art[i]) + +for x in art: + print(x) diff --git a/Practice/mvolobuev/lec5 task5_1.py b/Practice/mvolobuev/lec5 task5_1.py index 0afe6155..91d7fd71 100644 --- a/Practice/mvolobuev/lec5 task5_1.py +++ b/Practice/mvolobuev/lec5 task5_1.py @@ -1,12 +1,10 @@ # Замена Tab на пробелы h = int(input("Введите количество пробелов вместо Tab: ")) -i = 0 with open("Piton.txt", "r", encoding="utf-8") as f1: for s in f1: slist.append(s.expandtabs(tabsize=h)) - i += 1 print(slist) with open("Piton.txt","w",encoding= "utf-8") as f: - for i1 in range(0, i): + for i1 in range(0, len(slist)): f.write(slist[i1]) diff --git a/Practice/mvolobuev/lec5 task5_2.py b/Practice/mvolobuev/lec5 task5_2.py index 7d8bafb4..e1b6d1e4 100644 --- a/Practice/mvolobuev/lec5 task5_2.py +++ b/Practice/mvolobuev/lec5 task5_2.py @@ -1,13 +1,10 @@ # Замена проберов на Tab -i = 0 s2 = "" with open("Piton.txt", "r", encoding="utf-8") as f1: - slist = "" for s in f1: s1 = " " + s.strip() slist = slist + s2 + s1.replace(" ", "\t", 1) s2= "\n" - i += 1 print(slist) with open("Piton.txt","w",encoding= "utf-8") as f: From 9ed57a3c16313a298097887bedcfd6759103ae80 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Fri, 29 Sep 2023 19:10:48 +0300 Subject: [PATCH 14/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task4.py | 7 ++----- Practice/mvolobuev/lec5 task5_1.py | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Practice/mvolobuev/lec5 task4.py b/Practice/mvolobuev/lec5 task4.py index 2a3f3153..99432259 100644 --- a/Practice/mvolobuev/lec5 task4.py +++ b/Practice/mvolobuev/lec5 task4.py @@ -8,12 +8,9 @@ for i in range(0, len(art)): for j in range(0, len(art[0])): g = art[i] - if g[j] == k: + if g[j] == k and j not in st: st[i1] = j - if j == st[i1-1] or j == st[i1-2] or j == st[i1-3]: - st[i1] = -1 - else: - i1 += 1 + i1 += 1 for j1 in range(0, i1): s1 = st[j1] diff --git a/Practice/mvolobuev/lec5 task5_1.py b/Practice/mvolobuev/lec5 task5_1.py index 91d7fd71..51aac10f 100644 --- a/Practice/mvolobuev/lec5 task5_1.py +++ b/Practice/mvolobuev/lec5 task5_1.py @@ -1,5 +1,6 @@ # Замена Tab на пробелы h = int(input("Введите количество пробелов вместо Tab: ")) +slist = [] with open("Piton.txt", "r", encoding="utf-8") as f1: for s in f1: slist.append(s.expandtabs(tabsize=h)) From d7fe30f981e821613d59c4f261a5b00b01e154de Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Sat, 30 Sep 2023 07:40:05 +0300 Subject: [PATCH 15/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task5_2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Practice/mvolobuev/lec5 task5_2.py b/Practice/mvolobuev/lec5 task5_2.py index e1b6d1e4..f2882c05 100644 --- a/Practice/mvolobuev/lec5 task5_2.py +++ b/Practice/mvolobuev/lec5 task5_2.py @@ -1,9 +1,12 @@ # Замена проберов на Tab +s1 = "" s2 = "" +slist = "" with open("Piton.txt", "r", encoding="utf-8") as f1: for s in f1: s1 = " " + s.strip() - slist = slist + s2 + s1.replace(" ", "\t", 1) + s3 = s1.replace(" ", "\t", 1) + slist = slist + s2 + s3 s2= "\n" print(slist) From 10686e45eda10d7f78406b3ca06c0b85b941a986 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Mon, 2 Oct 2023 08:56:13 +0300 Subject: [PATCH 16/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task5_2.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Practice/mvolobuev/lec5 task5_2.py b/Practice/mvolobuev/lec5 task5_2.py index f2882c05..7a046928 100644 --- a/Practice/mvolobuev/lec5 task5_2.py +++ b/Practice/mvolobuev/lec5 task5_2.py @@ -1,13 +1,11 @@ # Замена проберов на Tab s1 = "" -s2 = "" +s2 = "\n" slist = "" with open("Piton.txt", "r", encoding="utf-8") as f1: for s in f1: s1 = " " + s.strip() - s3 = s1.replace(" ", "\t", 1) - slist = slist + s2 + s3 - s2= "\n" + slist += s1.replace(" ", "\t") + s2 print(slist) with open("Piton.txt","w",encoding= "utf-8") as f: From d5240ebba81e74f5cccb8b33d4b21ee8fff74392 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Fri, 6 Oct 2023 09:21:40 +0300 Subject: [PATCH 17/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=205,?= =?UTF-8?q?=20=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec5 task5_2.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Practice/mvolobuev/lec5 task5_2.py b/Practice/mvolobuev/lec5 task5_2.py index 7a046928..31447d42 100644 --- a/Practice/mvolobuev/lec5 task5_2.py +++ b/Practice/mvolobuev/lec5 task5_2.py @@ -1,11 +1,9 @@ # Замена проберов на Tab -s1 = "" s2 = "\n" slist = "" with open("Piton.txt", "r", encoding="utf-8") as f1: for s in f1: - s1 = " " + s.strip() - slist += s1.replace(" ", "\t") + s2 + slist += s.replace(" ", "\t") + s2 print(slist) with open("Piton.txt","w",encoding= "utf-8") as f: From 136c38fa08ad2dd2ab79cfb11aee2151e24498b7 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Sun, 8 Oct 2023 17:57:31 +0300 Subject: [PATCH 18/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=206,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201=20=D0=B8=202.?= =?UTF-8?q?=20=D0=A1=20=D1=82=D1=80=D0=B5=D1=82=D1=8C=D0=B8=D0=BC=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BA=D0=B0=20=D0=BD=D0=B5=20=D1=80=D0=B0=D0=B7=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=BB=D1=81=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec6_task1.py | 23 +++++++++ Practice/mvolobuev/lec6_task2.py | 83 ++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 Practice/mvolobuev/lec6_task1.py create mode 100644 Practice/mvolobuev/lec6_task2.py diff --git a/Practice/mvolobuev/lec6_task1.py b/Practice/mvolobuev/lec6_task1.py new file mode 100644 index 00000000..bbf75bbb --- /dev/null +++ b/Practice/mvolobuev/lec6_task1.py @@ -0,0 +1,23 @@ +# Задание 1. Класс и экземпляры классов +class Tank_Vybor: + def __init__(self, marka, cvet, ckorost): + self.marka = marka + self.cvet = cvet + self.ckorost = ckorost + + +w = Tank_Vybor +w.marka = "T-34" +w.cvet = "Зеленый" +w.ckorost = "50 км/ч" +print(w.marka) +print(w.cvet) +print(w.ckorost) +print("************************************") +w1 = Tank_Vybor +w1.marka = "T-80" +w1.cvet = "Песочный" +w1.ckorost = "80 км/ч" +print(w1.marka) +print(w1.cvet) +print(w1.ckorost) diff --git a/Practice/mvolobuev/lec6_task2.py b/Practice/mvolobuev/lec6_task2.py new file mode 100644 index 00000000..0b77be8a --- /dev/null +++ b/Practice/mvolobuev/lec6_task2.py @@ -0,0 +1,83 @@ +# Задание 2. Класс Duck. +class Duck: + cvet = "Зеленый" + def __init__(self, name, weight): + self.name = name + self.weight = weight + print(f"Утка {self.name}.") + + @staticmethod + def print_crack(): + print("Crack") + + @classmethod + def print_color(cls, new_color): + cls.cvet = new_color + + def print_name_weight(self): + print(f"{self.name}, {self.weight}") + + def __add__(self, other): + sum_weight = self.weight + other.weight + new_duck = Duck(None, sum_weight) + return new_duck + + def __repr__(self): + return f"Duck at {id(self)}:{self.name}, {self.weight}, {self.cvet}" + + def __str__(self): + return f"Duck:{self.name}, {self.weight}, {self.cvet}" + + def __lt__(self, other): + if self.name == other.name: + return self.weight < other.weight + else: + return self.weight > other.weight + + def __gt__(self, other): + return self.weight > other.weight + + + def __eq__(self, other): + return self.weight == other.weight + + + def __ne__(self, other): + return self.weight != other.weight + + +class Duckling(Duck): + pass + + +w = Duckling(name="Утенок",weight=5) +w.print_crack() +w.print_color("Серый") +print(w.cvet) +w.print_name_weight() +print(w) +print(repr(w)) + +#if __name__ == __main__: +d1 = Duck("Кря", 50) +d2 = Duck("Ряк", 100) +d3 = Duck("Кря", 100) +d4 = Duck("Ркя", 90) + +s = d3 + d4 +print(f"Общий вес уток = {s.weight}") +print(d2 > d4) +print(d2 < d4) +print(d2 == d4) +print(d2 != d4) + +# Попробовал сортировку с < и > по отдельности все работает. +# При наличии двух магических методов < и >, используется первый в записи. +# Для равно и неравно естественно сортировка не работает. +spisok = [d1, d2, d3, d4] +for i in spisok: + print(i) +print("**********************") +spisok.sort() +for i in spisok: + print(i) From a59e7e319cdfec7d638142749bda8a01ed159407 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Mon, 9 Oct 2023 09:05:15 +0300 Subject: [PATCH 19/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=206,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201=20=D0=B8=202?= =?UTF-8?q?=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec6_task1.py | 10 ++-------- Practice/mvolobuev/lec6_task2.py | 8 ++++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Practice/mvolobuev/lec6_task1.py b/Practice/mvolobuev/lec6_task1.py index bbf75bbb..952d66fa 100644 --- a/Practice/mvolobuev/lec6_task1.py +++ b/Practice/mvolobuev/lec6_task1.py @@ -6,18 +6,12 @@ def __init__(self, marka, cvet, ckorost): self.ckorost = ckorost -w = Tank_Vybor -w.marka = "T-34" -w.cvet = "Зеленый" -w.ckorost = "50 км/ч" +w = Tank_Vybor("T-34", "Зеленый", "50 км/ч") print(w.marka) print(w.cvet) print(w.ckorost) print("************************************") -w1 = Tank_Vybor -w1.marka = "T-80" -w1.cvet = "Песочный" -w1.ckorost = "80 км/ч" +w1 = Tank_Vybor("T-80", "Песочный", "80 км/ч") print(w1.marka) print(w1.cvet) print(w1.ckorost) diff --git a/Practice/mvolobuev/lec6_task2.py b/Practice/mvolobuev/lec6_task2.py index 0b77be8a..94611d3e 100644 --- a/Practice/mvolobuev/lec6_task2.py +++ b/Practice/mvolobuev/lec6_task2.py @@ -12,7 +12,8 @@ def print_crack(): @classmethod def print_color(cls, new_color): - cls.cvet = new_color +# cls.cvet = new_color + print(new_color) def print_name_weight(self): print(f"{self.name}, {self.weight}") @@ -35,7 +36,10 @@ def __lt__(self, other): return self.weight > other.weight def __gt__(self, other): - return self.weight > other.weight + if self.name == other.name: + return self.weight > other.weight + else: + return self.weight < other.weight def __eq__(self, other): From 0c0b3a837c34fc5f640b73afc7f3c8855b7ffcf4 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Mon, 9 Oct 2023 13:54:03 +0300 Subject: [PATCH 20/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=206,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=202=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec6_task2.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Practice/mvolobuev/lec6_task2.py b/Practice/mvolobuev/lec6_task2.py index 94611d3e..ada38d92 100644 --- a/Practice/mvolobuev/lec6_task2.py +++ b/Practice/mvolobuev/lec6_task2.py @@ -12,8 +12,8 @@ def print_crack(): @classmethod def print_color(cls, new_color): -# cls.cvet = new_color - print(new_color) + cls.cvet = new_color + print(cls.cvet) def print_name_weight(self): print(f"{self.name}, {self.weight}") @@ -33,13 +33,13 @@ def __lt__(self, other): if self.name == other.name: return self.weight < other.weight else: - return self.weight > other.weight + return self.name < other.name def __gt__(self, other): if self.name == other.name: return self.weight > other.weight else: - return self.weight < other.weight + return self.name > other.name def __eq__(self, other): From 52224808f69916f4115952e0e0b81cf7d9d387ba Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Mon, 9 Oct 2023 15:29:41 +0300 Subject: [PATCH 21/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=206,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=203.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec6_task2.py | 35 ++++++++++++++--------------- Practice/mvolobuev/lec6_task3.py | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 Practice/mvolobuev/lec6_task3.py diff --git a/Practice/mvolobuev/lec6_task2.py b/Practice/mvolobuev/lec6_task2.py index ada38d92..52e6cc39 100644 --- a/Practice/mvolobuev/lec6_task2.py +++ b/Practice/mvolobuev/lec6_task2.py @@ -1,6 +1,6 @@ # Задание 2. Класс Duck. class Duck: - cvet = "Зеленый" + color = "Зеленый" def __init__(self, name, weight): self.name = name self.weight = weight @@ -15,13 +15,14 @@ def print_color(cls, new_color): cls.cvet = new_color print(cls.cvet) - def print_name_weight(self): + def print_name_weight (self): print(f"{self.name}, {self.weight}") - def __add__(self, other): - sum_weight = self.weight + other.weight - new_duck = Duck(None, sum_weight) - return new_duck + def __lt__(self, other): + if self.name == other.name: + return self.weight < other.weight + else: + return self.name < other.name def __repr__(self): return f"Duck at {id(self)}:{self.name}, {self.weight}, {self.cvet}" @@ -29,11 +30,11 @@ def __repr__(self): def __str__(self): return f"Duck:{self.name}, {self.weight}, {self.cvet}" - def __lt__(self, other): - if self.name == other.name: - return self.weight < other.weight - else: - return self.name < other.name + + def __add__(self, other): + sum_weight = self.weight + other.weight + new_duck = Duck(None, sum_weight) + return new_duck def __gt__(self, other): if self.name == other.name: @@ -45,16 +46,14 @@ def __gt__(self, other): def __eq__(self, other): return self.weight == other.weight - def __ne__(self, other): - return self.weight != other.weight - + return self.weight == other.weight -class Duckling(Duck): +class Duckling(): pass -w = Duckling(name="Утенок",weight=5) +w = Duck("Утенок", 5) w.print_crack() w.print_color("Серый") print(w.cvet) @@ -62,7 +61,6 @@ class Duckling(Duck): print(w) print(repr(w)) -#if __name__ == __main__: d1 = Duck("Кря", 50) d2 = Duck("Ряк", 100) d3 = Duck("Кря", 100) @@ -74,7 +72,6 @@ class Duckling(Duck): print(d2 < d4) print(d2 == d4) print(d2 != d4) - # Попробовал сортировку с < и > по отдельности все работает. # При наличии двух магических методов < и >, используется первый в записи. # Для равно и неравно естественно сортировка не работает. @@ -84,4 +81,4 @@ class Duckling(Duck): print("**********************") spisok.sort() for i in spisok: - print(i) + print(i) \ No newline at end of file diff --git a/Practice/mvolobuev/lec6_task3.py b/Practice/mvolobuev/lec6_task3.py new file mode 100644 index 00000000..9dfe6599 --- /dev/null +++ b/Practice/mvolobuev/lec6_task3.py @@ -0,0 +1,38 @@ +# WrapStrFlle +import tempfile +import os + + +class WrapStrToFile: + def __init__(self): + self.filepach = tempfile.mktemp() + + + @property + def content(self): + try: + with open(self.filepach, "r", encoding="utf-8") as f1: + return f1.read() + except FileNotFoundError as e: + print(e) + return "File doesn't exist" + + @content.setter + def content(self, value): + with open(self.filepach, "w", encoding="utf-8") as f1: + f1.write(value) + + + @content.deleter + def content(self): + os.remove(self.filepach) + print("Файл удален") + + +wstf = WrapStrToFile() +print(wstf.content) +wstf.content= "test str" +print(wstf.content) +wstf.content = "text 2" +print(wstf.content) +del wstf.content # после этого файла не существует From f527aefbd1a48fccece1604968bdd594ed5a54dd Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Tue, 10 Oct 2023 09:24:20 +0300 Subject: [PATCH 22/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=206,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=202,3.=20=D0=98?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec6_task2.py | 10 +++++----- Practice/mvolobuev/lec6_task3.py | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Practice/mvolobuev/lec6_task2.py b/Practice/mvolobuev/lec6_task2.py index 52e6cc39..2eb1daa2 100644 --- a/Practice/mvolobuev/lec6_task2.py +++ b/Practice/mvolobuev/lec6_task2.py @@ -11,11 +11,11 @@ def print_crack(): print("Crack") @classmethod - def print_color(cls, new_color): - cls.cvet = new_color + def print_color(cls, new_cvet): + cls.cvet = new_cvet print(cls.cvet) - def print_name_weight (self): + def print_name_weight(self): print(f"{self.name}, {self.weight}") def __lt__(self, other): @@ -47,7 +47,7 @@ def __eq__(self, other): return self.weight == other.weight def __ne__(self, other): - return self.weight == other.weight + return self.weight != other.weight class Duckling(): pass @@ -81,4 +81,4 @@ class Duckling(): print("**********************") spisok.sort() for i in spisok: - print(i) \ No newline at end of file + print(i) diff --git a/Practice/mvolobuev/lec6_task3.py b/Practice/mvolobuev/lec6_task3.py index 9dfe6599..374c486a 100644 --- a/Practice/mvolobuev/lec6_task3.py +++ b/Practice/mvolobuev/lec6_task3.py @@ -7,7 +7,6 @@ class WrapStrToFile: def __init__(self): self.filepach = tempfile.mktemp() - @property def content(self): try: @@ -22,7 +21,6 @@ def content(self, value): with open(self.filepach, "w", encoding="utf-8") as f1: f1.write(value) - @content.deleter def content(self): os.remove(self.filepach) From baf62abacdee3000ad0f3911cb349b46f68f638e Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Tue, 10 Oct 2023 15:13:08 +0300 Subject: [PATCH 23/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=207,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=201,2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec7/lec7_task1.py | 14 ++++++++++++++ Practice/mvolobuev/lec7/lec7_task2.py | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Practice/mvolobuev/lec7/lec7_task1.py create mode 100644 Practice/mvolobuev/lec7/lec7_task2.py diff --git a/Practice/mvolobuev/lec7/lec7_task1.py b/Practice/mvolobuev/lec7/lec7_task1.py new file mode 100644 index 00000000..d2ca1357 --- /dev/null +++ b/Practice/mvolobuev/lec7/lec7_task1.py @@ -0,0 +1,14 @@ +# Написать класс Man, который принимает имя в конструкторе. +# Имеет метод solve_task, который просто выводит "I'm not ready yet". + +class Man: + def __init__(self, name): + self._name = name + + def solve_task(self): + print("I'm not ready yet") + + +imy = Man("Святослав") +print(imy._name) +imy.solve_task() diff --git a/Practice/mvolobuev/lec7/lec7_task2.py b/Practice/mvolobuev/lec7/lec7_task2.py new file mode 100644 index 00000000..a3f5a5a5 --- /dev/null +++ b/Practice/mvolobuev/lec7/lec7_task2.py @@ -0,0 +1,23 @@ +# Написать класс Pupil, у которого переопределен метод solve_task. +# На этот раз он будет думать от 3 до 6 секунд (c помощью метода sleep библиотеки time и randint библиотеки random). +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 __init__(self, name, student): + self._name = name + self._student = student + +stud = Pupil("Иван", "физики") +print(f"{stud._name}, направление {stud._student}") +i = random.randint(3,6) +time.sleep(i) +stud.solve_task() From ce6d5cf297ee4deef9f814867cc6fa5a13e14b3b Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Wed, 11 Oct 2023 11:11:13 +0300 Subject: [PATCH 24/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=207,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=202.=20=D0=98?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec7/lec7_task2.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Practice/mvolobuev/lec7/lec7_task2.py b/Practice/mvolobuev/lec7/lec7_task2.py index a3f5a5a5..c4313df3 100644 --- a/Practice/mvolobuev/lec7/lec7_task2.py +++ b/Practice/mvolobuev/lec7/lec7_task2.py @@ -16,8 +16,11 @@ def __init__(self, name, student): self._name = name self._student = student + def solve_task(self): + i = random.randint(3, 6) + time.sleep(i) + print("I'm not ready yet") + stud = Pupil("Иван", "физики") print(f"{stud._name}, направление {stud._student}") -i = random.randint(3,6) -time.sleep(i) stud.solve_task() From 42a4b1e30585bf5edb88031085797267afdfd1ad Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Thu, 12 Oct 2023 11:03:01 +0300 Subject: [PATCH 25/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=207,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=203.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/lec7/les7_task3.py | 156 ++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 Practice/mvolobuev/lec7/les7_task3.py diff --git a/Practice/mvolobuev/lec7/les7_task3.py b/Practice/mvolobuev/lec7/les7_task3.py new file mode 100644 index 00000000..11a43468 --- /dev/null +++ b/Practice/mvolobuev/lec7/les7_task3.py @@ -0,0 +1,156 @@ +# Реализовать систему, эмулирующую работу с банкоматами. +# Создать семейство классов банкоматов, хранящих определенные суммы и поддерживающих различные операции +# (одни банкоматы принимают и выдают наличные, другие позволяют еще и проводить онлайн платежи). +# Операции реализуются посредством методов, выводящих название операции и меняющих (при необходимости) +# количество наличных в банкомате. Для тестирования системы необходимо реализовать алгоритм, +# обходящий список банкоматов разного типа и запрашивающий у каждого банкомата информацию о количестве наличных +# и наборе поддерживаемых операций. +class Banks: + def __init__(self, address, deposit1, deposit2): + self.address = address + self.deposit1 = deposit1 + self.deposit2 = deposit2 + self.history = [] +# Пополнение счета + def vznos(self, i1): + self.deposit1 += i1 + + def snytie(self): + print(f"На Вашем счету {atm.deposit1}") + while True: + j = int(input("Введите сумму которую хотите снять:")) + if j < 0 or j > atm.deposit1: + break + else: + self.deposit1 = self.deposit1 - j + print(f"На Вашем счету осталось: {atm.deposit1}") + return + + def batm(self): + while True: + jatm = int(input("Введите, банкомат с которым Вы хотите работать: ")) + if jatm > 3: + break + else: + return jatm - 1 + +class Atm_ilyinka(Banks): + +# Снятие со счета + def snytie(self): + print(f"На Вашем счету {atm.deposit1}") + while True: + j = int(input("Введите сумму которую хотите снять:")) + if j < 0 or j > atm.deposit1: + break + else: + self.deposit1 = self.deposit1 - j + print(f"На Вашем счету осталось: {atm.deposit1}") + return + + def name(self): + print("Банкомат установлен на улице Ильинская") + print("<Вставьте карту") + print("<Банкомат осуществляет операции по снятию со счета") + io = 0 + return io + + +class Atm_vaneeva(Banks): +# Снятие со счета + def snytie(self): + print(f"На Вашем счету {atm.deposit1}") + while True: + j = int(input("Введите сумму которую хотите снять:")) + if j < 0 or j > atm.deposit1: + break + else: + self.deposit1 = self.deposit1 - j + print(f"На Вашем счету осталось: {atm.deposit1}") + return + + def name(self): + print("Банкомат установлен на улице Ванеева") + print("<Вставьте карту") + print("<Банкомат осуществляет операции по снятию и пополнению счета") + while True: + io = int(input(" Для пополнения счета введите - 0, для снятия со счета - 1 : ")) + if io > 1: + break + else: + return io + +# Пополнение счета + def popolnenie(self): + print(f"На Вашем счету {atm.deposit1}") + while True: + j = int(input("Введите сумму которую хотите положить на счет:")) + if j < 0: + break + else: + self.deposit1 = self.deposit1 + j + print(f"На Вашем счету: {atm.deposit1}") + return + +class Atm_pokrovka(Banks): + +# Снятие со счета + def snytie(self): + print(f"На Вашем счету {atm.deposit1}") + while True: + j = int(input("Введите сумму которую хотите снять:")) + if j < 0 or j > atm.deposit1: + break + else: + self.deposit1 = self.deposit1 - j + print(f"На Вашем счету осталось: {atm.deposit1}") + return + +# Пополнение счета + def popolnenie(self): + print(f"На Вашем счету {atm.deposit1}") + while True: + j = int(input("Введите сумму которую хотите положить на счет:")) + if j < 0: + break + else: + self.deposit1 = self.deposit1 + j + print(f"На Вашем счету: {atm.deposit1}") + return + +# Оплата квитанции + def slip(self): + print(f"На Вашем счету {atm.deposit2}") + while True: + j = int(input("Введите сумму с квитанции, которую хотите оплатить:")) + if j < 0: + break + else: + self.deposit2 = self.deposit2 - j + print(f"На Вашем счету: {atm.deposit2}") + return + + def name(self): + print("Банкомат установлен на улице Покровская") + print("<Вставьте карту") + print("<Банкомат осуществляет операции по снятию, пополнению счета и оплаты квитанций") + while True: + io = int(input(" Для пополнения счета введите - 0, для снятия со счета - 1, для оплаты квитанции - 2 : ")) + if io > 2: + break + else: + return io + +lst =[Atm_ilyinka("Ильинская", 1000, 0), Atm_vaneeva("Ванеева", 1000, 0), Atm_pokrovka("Покровская", 1000, 900)] +for i in range(0, len(lst)): + print(f"Банкомат -{i+1} на ул. {lst[i].address}, снятие наличных / Депозит-1 {lst[i].deposit1} / Депозит-2 {lst[i].deposit2} ") +jatm = Banks.batm(lst) +#atm = lst[jatm] +atm = lst[jatm] +iu = atm.name() +if iu == 0: + j1 = atm.snytie() +elif iu == 1: + j1 = atm.popolnenie() +else: + j1 = atm.slip() From f4526b4eb8d2af96c3a8f4e0255ebd644d994d79 Mon Sep 17 00:00:00 2001 From: Mikhail Volobuev Date: Thu, 12 Oct 2023 15:16:46 +0300 Subject: [PATCH 26/26] =?UTF-8?q?=D0=9B=D0=B5=D0=BA=D1=86=D0=B8=D1=8F=206,?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=203.=20=D0=9F?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=BE=D0=B1=D0=BE=D0=B2=D0=B0=D0=BB=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D0=BD=D1=83.=20=D0=98=D0=BD=D1=82=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D1=81=D0=BD=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/mvolobuev/{ => lec6}/lec6_task3.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Practice/mvolobuev/{ => lec6}/lec6_task3.py (100%) diff --git a/Practice/mvolobuev/lec6_task3.py b/Practice/mvolobuev/lec6/lec6_task3.py similarity index 100% rename from Practice/mvolobuev/lec6_task3.py rename to Practice/mvolobuev/lec6/lec6_task3.py