From 51ba277d6cbb1db7b42c9dee883a384cac6414e8 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Thu, 1 Sep 2022 12:41:02 +0300 Subject: [PATCH 01/48] changes1 --- Practice/GrishchenkoA/2.py | 6 ++++++ Practice/GrishchenkoA/Homework.py | 6 ++++++ Practice/GrishchenkoA/first.py | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 Practice/GrishchenkoA/2.py create mode 100644 Practice/GrishchenkoA/Homework.py create mode 100644 Practice/GrishchenkoA/first.py diff --git a/Practice/GrishchenkoA/2.py b/Practice/GrishchenkoA/2.py new file mode 100644 index 0000000..07b8c02 --- /dev/null +++ b/Practice/GrishchenkoA/2.py @@ -0,0 +1,6 @@ +start = input("Топлива было: ") +end = input("Топлива осталось: ") +distance = input("Расстояние: ") +diff = int(start) - int(end) +result = diff / int(distance) +print(f"Средний расход бензина: {result}") \ No newline at end of file diff --git a/Practice/GrishchenkoA/Homework.py b/Practice/GrishchenkoA/Homework.py new file mode 100644 index 0000000..85f703d --- /dev/null +++ b/Practice/GrishchenkoA/Homework.py @@ -0,0 +1,6 @@ +import math +radius = input("Введите радиус: ") +def square(r): + return math.pi * r ** 2 +result = square(int(radius)) +print(f"Площадь круга: {result}") diff --git a/Practice/GrishchenkoA/first.py b/Practice/GrishchenkoA/first.py new file mode 100644 index 0000000..e0498c5 --- /dev/null +++ b/Practice/GrishchenkoA/first.py @@ -0,0 +1,5 @@ +x=input("Введите число ") +y=input("Введите число ") +res=x+y +result=res%2 +print(f"Остаток: {result}") \ No newline at end of file From 028369a2581ce599e3da5ca6dabeddac73f68272 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 2 Sep 2022 15:54:44 +0300 Subject: [PATCH 02/48] changes1 --- Practice/GrishchenkoA/2.1.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Practice/GrishchenkoA/2.1.py diff --git a/Practice/GrishchenkoA/2.1.py b/Practice/GrishchenkoA/2.1.py new file mode 100644 index 0000000..2f59764 --- /dev/null +++ b/Practice/GrishchenkoA/2.1.py @@ -0,0 +1,10 @@ +import math +radius = input("Введите радиус: ") + + +def square(r): + return math.pi * r ** 2 + + +result = square(int(radius)) +print(f"Площадь круга: {result}") From a01532c8a57c81361c89ed3c65942661234a6f1e Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 2 Sep 2022 16:04:03 +0300 Subject: [PATCH 03/48] changes1 --- Practice/GrishchenkoA/{2.py => 2.2.py} | 0 Practice/GrishchenkoA/Homework.py | 6 ------ Practice/GrishchenkoA/first.py | 7 ++----- 3 files changed, 2 insertions(+), 11 deletions(-) rename Practice/GrishchenkoA/{2.py => 2.2.py} (100%) delete mode 100644 Practice/GrishchenkoA/Homework.py diff --git a/Practice/GrishchenkoA/2.py b/Practice/GrishchenkoA/2.2.py similarity index 100% rename from Practice/GrishchenkoA/2.py rename to Practice/GrishchenkoA/2.2.py diff --git a/Practice/GrishchenkoA/Homework.py b/Practice/GrishchenkoA/Homework.py deleted file mode 100644 index 85f703d..0000000 --- a/Practice/GrishchenkoA/Homework.py +++ /dev/null @@ -1,6 +0,0 @@ -import math -radius = input("Введите радиус: ") -def square(r): - return math.pi * r ** 2 -result = square(int(radius)) -print(f"Площадь круга: {result}") diff --git a/Practice/GrishchenkoA/first.py b/Practice/GrishchenkoA/first.py index e0498c5..c07a133 100644 --- a/Practice/GrishchenkoA/first.py +++ b/Practice/GrishchenkoA/first.py @@ -1,5 +1,2 @@ -x=input("Введите число ") -y=input("Введите число ") -res=x+y -result=res%2 -print(f"Остаток: {result}") \ No newline at end of file +city = input("Введите город: ") +print(f"Echo: {city}") \ No newline at end of file From 893e00744b90d109fb2640023a725aea7f894e79 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 5 Sep 2022 21:28:12 +0300 Subject: [PATCH 04/48] Version 1 --- Practice/GrishchenkoA/3.1.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Practice/GrishchenkoA/3.1.py diff --git a/Practice/GrishchenkoA/3.1.py b/Practice/GrishchenkoA/3.1.py new file mode 100644 index 0000000..d38055e --- /dev/null +++ b/Practice/GrishchenkoA/3.1.py @@ -0,0 +1,4 @@ +a=int(input("Введите длину прямоугольника: ")) +b=int(input("Введите ширину прямоугольника: ")) +p=2*a+2*b +print(f"Периметр прямоугольника равен: {p}") \ No newline at end of file From 28820e609fd34096c4b9694259afcf088a7a8d16 Mon Sep 17 00:00:00 2001 From: AleksandraG88 <112418943+AleksandraG88@users.noreply.github.com> Date: Mon, 5 Sep 2022 21:42:00 +0300 Subject: [PATCH 05/48] Update 2.1.py --- Practice/GrishchenkoA/2.1.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Practice/GrishchenkoA/2.1.py b/Practice/GrishchenkoA/2.1.py index 2f59764..b345b4e 100644 --- a/Practice/GrishchenkoA/2.1.py +++ b/Practice/GrishchenkoA/2.1.py @@ -1,10 +1,9 @@ import math -radius = input("Введите радиус: ") - def square(r): return math.pi * r ** 2 +radius = input("Введите радиус: ") result = square(int(radius)) print(f"Площадь круга: {result}") From 170567c93207bec23c1264d5cc90c8bf54ca4e96 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 5 Sep 2022 22:42:22 +0300 Subject: [PATCH 06/48] Version 1 --- Practice/GrishchenkoA/3.2.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Practice/GrishchenkoA/3.2.py diff --git a/Practice/GrishchenkoA/3.2.py b/Practice/GrishchenkoA/3.2.py new file mode 100644 index 0000000..6858d47 --- /dev/null +++ b/Practice/GrishchenkoA/3.2.py @@ -0,0 +1,4 @@ +time=int(input("Введите время, проведенное в пути: ")) +distance=int(input("Введите пройденное расстояние: ")) +speed=distance/time +print(f"Средняя скорость автомобиля равна: {speed}") From b4d9b75c8799819dd1482e41da93066eadc892bb Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 5 Sep 2022 23:00:45 +0300 Subject: [PATCH 07/48] Version 1 --- Practice/GrishchenkoA/3.4.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Practice/GrishchenkoA/3.4.py diff --git a/Practice/GrishchenkoA/3.4.py b/Practice/GrishchenkoA/3.4.py new file mode 100644 index 0000000..69602b9 --- /dev/null +++ b/Practice/GrishchenkoA/3.4.py @@ -0,0 +1,4 @@ +a=input("Введите слово: ") +с=a.replace("А","*",-1) +print(с) + From dd6a802c982d8ec61ee76a54e6ef9393467a0d84 Mon Sep 17 00:00:00 2001 From: AleksandraG88 <112418943+AleksandraG88@users.noreply.github.com> Date: Tue, 6 Sep 2022 23:41:35 +0300 Subject: [PATCH 08/48] Update 2.1.py --- Practice/GrishchenkoA/2.1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Practice/GrishchenkoA/2.1.py b/Practice/GrishchenkoA/2.1.py index b345b4e..55e7ed7 100644 --- a/Practice/GrishchenkoA/2.1.py +++ b/Practice/GrishchenkoA/2.1.py @@ -1,5 +1,6 @@ import math + def square(r): return math.pi * r ** 2 From 5b088a2b8ef1e25e159833e0493091effcd9734c Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Wed, 7 Sep 2022 00:10:19 +0300 Subject: [PATCH 09/48] Version 2 --- Practice/GrishchenkoA/3.1.py | 6 +++--- Practice/GrishchenkoA/3.2.py | 6 +++--- Practice/GrishchenkoA/3.4.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Practice/GrishchenkoA/3.1.py b/Practice/GrishchenkoA/3.1.py index d38055e..6d50de2 100644 --- a/Practice/GrishchenkoA/3.1.py +++ b/Practice/GrishchenkoA/3.1.py @@ -1,4 +1,4 @@ -a=int(input("Введите длину прямоугольника: ")) -b=int(input("Введите ширину прямоугольника: ")) -p=2*a+2*b +a = int(input("Введите длину прямоугольника: ")) +b = int(input("Введите ширину прямоугольника: ")) +p=2 * (a + b) print(f"Периметр прямоугольника равен: {p}") \ No newline at end of file diff --git a/Practice/GrishchenkoA/3.2.py b/Practice/GrishchenkoA/3.2.py index 6858d47..c07ae85 100644 --- a/Practice/GrishchenkoA/3.2.py +++ b/Practice/GrishchenkoA/3.2.py @@ -1,4 +1,4 @@ -time=int(input("Введите время, проведенное в пути: ")) -distance=int(input("Введите пройденное расстояние: ")) -speed=distance/time +time = int(input("Введите время, проведенное в пути: ")) +distance = int(input("Введите пройденное расстояние: ")) +speed = distance / time print(f"Средняя скорость автомобиля равна: {speed}") diff --git a/Practice/GrishchenkoA/3.4.py b/Practice/GrishchenkoA/3.4.py index 69602b9..13e54a8 100644 --- a/Practice/GrishchenkoA/3.4.py +++ b/Practice/GrishchenkoA/3.4.py @@ -1,4 +1,4 @@ -a=input("Введите слово: ") -с=a.replace("А","*",-1) -print(с) +word = input("Введите слово: ") +corrected_word = word.replace("А" , "*") +print(corrected_word) From 4002e0f76cc7033d9b7af5d28ca4ab64b1807370 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Wed, 7 Sep 2022 10:20:56 +0300 Subject: [PATCH 10/48] Version 1 --- Practice/GrishchenkoA/3.5.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Practice/GrishchenkoA/3.5.py diff --git a/Practice/GrishchenkoA/3.5.py b/Practice/GrishchenkoA/3.5.py new file mode 100644 index 0000000..470e573 --- /dev/null +++ b/Practice/GrishchenkoA/3.5.py @@ -0,0 +1,17 @@ +import math +word = input("Введите слово для проверки: ") +_lower = word.lower() +word_length = int(len(_lower)) +k = word_length / 2 +if word_length % 2 == 0: + z = int(k) +else: + z = k.__ceil__() +left = _lower[0 : z] +rights = _lower[-1 : int(k) - 1 : -1] +if left == rights: + print("True") +else: + print("False") + + From bbc000cdfd1dcb85b816bc7a2a42a6c95c6a26d9 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Wed, 7 Sep 2022 15:23:38 +0300 Subject: [PATCH 11/48] Version 1 --- Practice/GrishchenkoA/3.3.1.py | 4 ++++ Practice/GrishchenkoA/3.3.2.py | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 Practice/GrishchenkoA/3.3.1.py create mode 100644 Practice/GrishchenkoA/3.3.2.py diff --git a/Practice/GrishchenkoA/3.3.1.py b/Practice/GrishchenkoA/3.3.1.py new file mode 100644 index 0000000..ec8831e --- /dev/null +++ b/Practice/GrishchenkoA/3.3.1.py @@ -0,0 +1,4 @@ +password = int(input("Введите пароль :")) +key = 888 +result = password ^ key +print(result) \ No newline at end of file diff --git a/Practice/GrishchenkoA/3.3.2.py b/Practice/GrishchenkoA/3.3.2.py new file mode 100644 index 0000000..8d992ce --- /dev/null +++ b/Practice/GrishchenkoA/3.3.2.py @@ -0,0 +1,4 @@ +code = int(input("Введите зашифрованный код :")) +key = 888 +password = code ^ key +print(password) \ No newline at end of file From 18e9a0b56ebce747ee751fcb5aa17a3a7ce50b46 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Thu, 8 Sep 2022 11:00:30 +0300 Subject: [PATCH 12/48] Version 2 --- Practice/GrishchenkoA/3.1.py | 2 +- Practice/GrishchenkoA/3.5.py | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Practice/GrishchenkoA/3.1.py b/Practice/GrishchenkoA/3.1.py index 6d50de2..bb9f8a9 100644 --- a/Practice/GrishchenkoA/3.1.py +++ b/Practice/GrishchenkoA/3.1.py @@ -1,4 +1,4 @@ a = int(input("Введите длину прямоугольника: ")) b = int(input("Введите ширину прямоугольника: ")) -p=2 * (a + b) +p = 2 * (a + b) print(f"Периметр прямоугольника равен: {p}") \ No newline at end of file diff --git a/Practice/GrishchenkoA/3.5.py b/Practice/GrishchenkoA/3.5.py index 470e573..a20b252 100644 --- a/Practice/GrishchenkoA/3.5.py +++ b/Practice/GrishchenkoA/3.5.py @@ -1,17 +1,8 @@ import math word = input("Введите слово для проверки: ") _lower = word.lower() -word_length = int(len(_lower)) -k = word_length / 2 -if word_length % 2 == 0: - z = int(k) -else: - z = k.__ceil__() -left = _lower[0 : z] -rights = _lower[-1 : int(k) - 1 : -1] -if left == rights: - print("True") -else: - print("False") +left = _lower[0 : ] +rights = _lower[-1 : : -1] +print(left == rights) From 35f043bd5e5548d1081d5b007f6f7b9ec6cedbf5 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 13 Sep 2022 22:13:43 +0300 Subject: [PATCH 13/48] Version 1 --- Practice/GrishchenkoA/4.1.py | 0 Practice/GrishchenkoA/4.2.py | 0 Practice/GrishchenkoA/4.3.py | 0 Practice/GrishchenkoA/4.4.py | 0 Practice/GrishchenkoA/4.5.py | 0 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Practice/GrishchenkoA/4.1.py create mode 100644 Practice/GrishchenkoA/4.2.py create mode 100644 Practice/GrishchenkoA/4.3.py create mode 100644 Practice/GrishchenkoA/4.4.py create mode 100644 Practice/GrishchenkoA/4.5.py diff --git a/Practice/GrishchenkoA/4.1.py b/Practice/GrishchenkoA/4.1.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/4.2.py b/Practice/GrishchenkoA/4.2.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/4.3.py b/Practice/GrishchenkoA/4.3.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/4.4.py b/Practice/GrishchenkoA/4.4.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/4.5.py b/Practice/GrishchenkoA/4.5.py new file mode 100644 index 0000000..e69de29 From 9ff0238fbddf5f5daf9afd4ee3e2db7769725f28 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 13 Sep 2022 22:17:56 +0300 Subject: [PATCH 14/48] Version 1 --- Practice/GrishchenkoA/4.8.py | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Practice/GrishchenkoA/4.8.py diff --git a/Practice/GrishchenkoA/4.8.py b/Practice/GrishchenkoA/4.8.py new file mode 100644 index 0000000..b4481aa --- /dev/null +++ b/Practice/GrishchenkoA/4.8.py @@ -0,0 +1,38 @@ +import random + +play = ["камень", "ножницы", "бумага"] +while (player_1 := input("Введите ваш вариант: ").lower()) != "хватит": + player_2 = random.choice(play) + + if player_1 == "камень": + if player_2 == "камень": + print("Вариант компьютера: камень") + print("Ничья") + elif player_2 == "ножницы": + print("Вариант компьютера: ножницы") + print("Вы выиграли") + elif player_2 == "бумага": + print("Вариант компьютера: бумага") + print("Вы проиграли") + elif player_1 == "ножницы": + + if player_2 == "камень": + print("Вариант компьютера: камень") + print("Вы проиграли") + elif player_2 == "ножницы": + print("Вариант компьютера: ножницы") + print("Ничья") + elif player_2 == "бумага": + print("Вариант компьютера: бумага") + print("Вы выиграли") + elif player_1 == "бумага": + + if player_2 == "камень": + print("Вариант компьютера: камень") + print("Вы выиграли") + elif player_2 == "ножницы": + print("Вариант компьютера: ножниицы") + print("Вы проиграли") + elif player_2 == "бумага": + print("Вариант компьютера: бумага") + print("Ничья") \ No newline at end of file From 3abf1a3b1c38457ab407d47b323d5a1d7fd83466 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 13 Sep 2022 22:24:00 +0300 Subject: [PATCH 15/48] Version 1 --- Practice/GrishchenkoA/4.1.py | 14 ++++++++++++++ Practice/GrishchenkoA/4.2.py | 3 +++ Practice/GrishchenkoA/4.3.py | 16 ++++++++++++++++ Practice/GrishchenkoA/4.4.py | 5 +++++ Practice/GrishchenkoA/4.5.py | 19 +++++++++++++++++++ 5 files changed, 57 insertions(+) diff --git a/Practice/GrishchenkoA/4.1.py b/Practice/GrishchenkoA/4.1.py index e69de29..d140312 100644 --- a/Practice/GrishchenkoA/4.1.py +++ b/Practice/GrishchenkoA/4.1.py @@ -0,0 +1,14 @@ +number = 1 +while number <= 100: + if number % 15 == 0: + print("FizzBuzz") + number += 1 + elif number % 5 == 0: + print("Buzz") + number += 1 + elif number % 3 == 0: + print("Fizz") + number += 1 + else: + print(number) + number += 1 diff --git a/Practice/GrishchenkoA/4.2.py b/Practice/GrishchenkoA/4.2.py index e69de29..8f26ae2 100644 --- a/Practice/GrishchenkoA/4.2.py +++ b/Practice/GrishchenkoA/4.2.py @@ -0,0 +1,3 @@ +numbers = input("Введите пятизначное число: ") +for i, d in enumerate(numbers): + print(f"{i+1} цифра равна {int(d)}") \ No newline at end of file diff --git a/Practice/GrishchenkoA/4.3.py b/Practice/GrishchenkoA/4.3.py index e69de29..6f4926b 100644 --- a/Practice/GrishchenkoA/4.3.py +++ b/Practice/GrishchenkoA/4.3.py @@ -0,0 +1,16 @@ +symbol = input("Введите числовой символ: ") +numbers="" +while symbol.lower() != "stop": + if symbol.isdecimal(): + numbers += symbol + symbol = input("Введите числовой символ: ") + else: + print("Введен нечисловой символ") + symbol = input("Введите числовой символ: ") +else: + print(f"Сформированное число: {int(numbers)}") + + + + + diff --git a/Practice/GrishchenkoA/4.4.py b/Practice/GrishchenkoA/4.4.py index e69de29..3bcec3d 100644 --- a/Practice/GrishchenkoA/4.4.py +++ b/Practice/GrishchenkoA/4.4.py @@ -0,0 +1,5 @@ +import random + +answer = ["Ты сам-то понял, что написал?", "Аргументируй", "И?"] +while (request := input("Введите запрос: ")) != "хватит": + print(random.choice(answer)) \ No newline at end of file diff --git a/Practice/GrishchenkoA/4.5.py b/Practice/GrishchenkoA/4.5.py index e69de29..fc9e394 100644 --- a/Practice/GrishchenkoA/4.5.py +++ b/Practice/GrishchenkoA/4.5.py @@ -0,0 +1,19 @@ +import random + +range = input("Введите диапазон чисел: ").split() +hidden_numbers = random.randint(int(range[0]), int(range[1])) +numbers_1 = input("Угадайте целое число: ") +if numbers_1.isdigit(): + while int(numbers_1) != int(hidden_numbers): + if int(numbers_1) < hidden_numbers: + print("Загаданное число больше введенного") + numbers_1 = input("Угадайте целое число: ") + elif int(numbers_1) > hidden_numbers: + print("Загаданное число меньше введенного") + numbers_1 = input("Угадайте целое число: ") + print("Вы угадали") +else: + print("Вы ввели нечисловой символ") + + + From 5a56e7f9371df1008da30034727b5c1b801c2540 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 13 Sep 2022 22:28:28 +0300 Subject: [PATCH 16/48] Version 3 --- Practice/GrishchenkoA/3.1.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Practice/GrishchenkoA/3.1.py b/Practice/GrishchenkoA/3.1.py index bb9f8a9..7d9f74b 100644 --- a/Practice/GrishchenkoA/3.1.py +++ b/Practice/GrishchenkoA/3.1.py @@ -1,4 +1,5 @@ a = int(input("Введите длину прямоугольника: ")) b = int(input("Введите ширину прямоугольника: ")) -p = 2 * (a + b) -print(f"Периметр прямоугольника равен: {p}") \ No newline at end of file +p = 2*(a + b) +print(f"Периметр прямоугольника " + f": {p}") \ No newline at end of file From 768687990de5d01db60b2a4453048f270f625b40 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 13 Sep 2022 22:29:30 +0300 Subject: [PATCH 17/48] Version 3 --- Practice/GrishchenkoA/3.1.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Practice/GrishchenkoA/3.1.py b/Practice/GrishchenkoA/3.1.py index 7d9f74b..cc770b8 100644 --- a/Practice/GrishchenkoA/3.1.py +++ b/Practice/GrishchenkoA/3.1.py @@ -1,5 +1,4 @@ a = int(input("Введите длину прямоугольника: ")) b = int(input("Введите ширину прямоугольника: ")) p = 2*(a + b) -print(f"Периметр прямоугольника " - f": {p}") \ No newline at end of file +print(f"Периметр прямоугольника "f": {p}") \ No newline at end of file From 3bfc44b51dd085cf4653c3689b078c38eeb48a43 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 13 Sep 2022 22:34:40 +0300 Subject: [PATCH 18/48] Version 3 --- Practice/GrishchenkoA/3.5.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Practice/GrishchenkoA/3.5.py b/Practice/GrishchenkoA/3.5.py index a20b252..375913a 100644 --- a/Practice/GrishchenkoA/3.5.py +++ b/Practice/GrishchenkoA/3.5.py @@ -1,8 +1,7 @@ -import math word = input("Введите слово для проверки: ") _lower = word.lower() -left = _lower[0 : ] -rights = _lower[-1 : : -1] +left = _lower +rights = _lower[::-1] print(left == rights) From 3478f1c72d310defe271fa3c81c93cced896d1ee Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Wed, 14 Sep 2022 08:43:49 +0300 Subject: [PATCH 19/48] =?UTF-8?q?=D0=9D=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=BE=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE?= =?UTF-8?q?=20=D0=BE=D0=B4=D0=B8=D0=BD=20int(numbers=5F1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/4.5.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Practice/GrishchenkoA/4.5.py b/Practice/GrishchenkoA/4.5.py index fc9e394..f6ec06c 100644 --- a/Practice/GrishchenkoA/4.5.py +++ b/Practice/GrishchenkoA/4.5.py @@ -4,16 +4,20 @@ hidden_numbers = random.randint(int(range[0]), int(range[1])) numbers_1 = input("Угадайте целое число: ") if numbers_1.isdigit(): - while int(numbers_1) != int(hidden_numbers): - if int(numbers_1) < hidden_numbers: + while int(numbers_1) != hidden_numbers: + if not numbers_1.isdigit(): + print("Вы ввели нечисловой символ") + break + else: + numbers_1 = int(numbers_1) + if numbers_1 < hidden_numbers: print("Загаданное число больше введенного") - numbers_1 = input("Угадайте целое число: ") - elif int(numbers_1) > hidden_numbers: + elif numbers_1 > hidden_numbers: print("Загаданное число меньше введенного") - numbers_1 = input("Угадайте целое число: ") + numbers_1 = input("Угадайте целое число: ") print("Вы угадали") else: - print("Вы ввели нечисловой символ") + print("Вы ввели нечисловой символ") From 541f31c5d7f1ddc953b71a0e4a61fc5d9c08534d Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Wed, 14 Sep 2022 08:46:42 +0300 Subject: [PATCH 20/48] Version 2 --- Practice/GrishchenkoA/3.1.py | 2 +- Practice/GrishchenkoA/4.1.py | 5 +---- Practice/GrishchenkoA/4.2.py | 2 +- Practice/GrishchenkoA/4.3.py | 5 +---- Practice/GrishchenkoA/4.8.py | 11 +---------- 5 files changed, 5 insertions(+), 20 deletions(-) diff --git a/Practice/GrishchenkoA/3.1.py b/Practice/GrishchenkoA/3.1.py index cc770b8..8cc6411 100644 --- a/Practice/GrishchenkoA/3.1.py +++ b/Practice/GrishchenkoA/3.1.py @@ -1,4 +1,4 @@ a = int(input("Введите длину прямоугольника: ")) b = int(input("Введите ширину прямоугольника: ")) p = 2*(a + b) -print(f"Периметр прямоугольника "f": {p}") \ No newline at end of file +print(f"Периметр прямоугольника: {p}") \ No newline at end of file diff --git a/Practice/GrishchenkoA/4.1.py b/Practice/GrishchenkoA/4.1.py index d140312..05b0633 100644 --- a/Practice/GrishchenkoA/4.1.py +++ b/Practice/GrishchenkoA/4.1.py @@ -2,13 +2,10 @@ while number <= 100: if number % 15 == 0: print("FizzBuzz") - number += 1 elif number % 5 == 0: print("Buzz") - number += 1 elif number % 3 == 0: print("Fizz") - number += 1 else: print(number) - number += 1 + number += 1 diff --git a/Practice/GrishchenkoA/4.2.py b/Practice/GrishchenkoA/4.2.py index 8f26ae2..a7829ce 100644 --- a/Practice/GrishchenkoA/4.2.py +++ b/Practice/GrishchenkoA/4.2.py @@ -1,3 +1,3 @@ numbers = input("Введите пятизначное число: ") for i, d in enumerate(numbers): - print(f"{i+1} цифра равна {int(d)}") \ No newline at end of file + print(f"{i+1} цифра равна {d}") \ No newline at end of file diff --git a/Practice/GrishchenkoA/4.3.py b/Practice/GrishchenkoA/4.3.py index 6f4926b..e02ffdb 100644 --- a/Practice/GrishchenkoA/4.3.py +++ b/Practice/GrishchenkoA/4.3.py @@ -1,12 +1,9 @@ -symbol = input("Введите числовой символ: ") numbers="" -while symbol.lower() != "stop": +while (symbol := input("Введите числовой символ: ")).lower() != "stop": if symbol.isdecimal(): numbers += symbol - symbol = input("Введите числовой символ: ") else: print("Введен нечисловой символ") - symbol = input("Введите числовой символ: ") else: print(f"Сформированное число: {int(numbers)}") diff --git a/Practice/GrishchenkoA/4.8.py b/Practice/GrishchenkoA/4.8.py index b4481aa..a58345b 100644 --- a/Practice/GrishchenkoA/4.8.py +++ b/Practice/GrishchenkoA/4.8.py @@ -3,36 +3,27 @@ play = ["камень", "ножницы", "бумага"] while (player_1 := input("Введите ваш вариант: ").lower()) != "хватит": player_2 = random.choice(play) - + print(f"Вариант компьютера: {player_2}") if player_1 == "камень": if player_2 == "камень": - print("Вариант компьютера: камень") print("Ничья") elif player_2 == "ножницы": - print("Вариант компьютера: ножницы") print("Вы выиграли") elif player_2 == "бумага": - print("Вариант компьютера: бумага") print("Вы проиграли") elif player_1 == "ножницы": if player_2 == "камень": - print("Вариант компьютера: камень") print("Вы проиграли") elif player_2 == "ножницы": - print("Вариант компьютера: ножницы") print("Ничья") elif player_2 == "бумага": - print("Вариант компьютера: бумага") print("Вы выиграли") elif player_1 == "бумага": if player_2 == "камень": - print("Вариант компьютера: камень") print("Вы выиграли") elif player_2 == "ножницы": - print("Вариант компьютера: ножниицы") print("Вы проиграли") elif player_2 == "бумага": - print("Вариант компьютера: бумага") print("Ничья") \ No newline at end of file From c8877d56a447bf5dd219e8a6971f23f5759cb4c7 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Thu, 15 Sep 2022 10:03:42 +0300 Subject: [PATCH 21/48] Version 1 --- Practice/GrishchenkoA/4.6.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Practice/GrishchenkoA/4.6.py diff --git a/Practice/GrishchenkoA/4.6.py b/Practice/GrishchenkoA/4.6.py new file mode 100644 index 0000000..a6c24ca --- /dev/null +++ b/Practice/GrishchenkoA/4.6.py @@ -0,0 +1,19 @@ +def choose_max(a, b): + if a > b: + max_1 = a + else: + max_1 = b + print(f"Большее число из введенных: {max_1}") + + +def finds_max(a, b): + if a > b: + max_2 = a + else: + max_2 = b + return max_2 + + +a, b=map(int, input("Введите два числа: ").split()) +choose_max(a, b) +finds_max(a, b) \ No newline at end of file From 0360793ba818bc28fb40d9a0a591fbb4f49e4065 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Thu, 15 Sep 2022 13:54:28 +0300 Subject: [PATCH 22/48] Version 2 --- Practice/GrishchenkoA/4.6.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/GrishchenkoA/4.6.py b/Practice/GrishchenkoA/4.6.py index a6c24ca..c5e1081 100644 --- a/Practice/GrishchenkoA/4.6.py +++ b/Practice/GrishchenkoA/4.6.py @@ -14,6 +14,6 @@ def finds_max(a, b): return max_2 -a, b=map(int, input("Введите два числа: ").split()) +a, b = map(int, input("Введите два числа: ").split()) choose_max(a, b) finds_max(a, b) \ No newline at end of file From a6449017a65b50ed4e0fa532aa62570e6fe2db46 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Sat, 17 Sep 2022 17:21:02 +0300 Subject: [PATCH 23/48] Version 1 --- Practice/GrishchenkoA/4.7.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Practice/GrishchenkoA/4.7.py diff --git a/Practice/GrishchenkoA/4.7.py b/Practice/GrishchenkoA/4.7.py new file mode 100644 index 0000000..e69de29 From 2e6f0db2ea3e030480f4dbbd1e115fa818f19dfd Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 19 Sep 2022 10:04:50 +0300 Subject: [PATCH 24/48] Version 1 --- Practice/GrishchenkoA/4.7.py | 12 +++++++----- Practice/GrishchenkoA/5.1.py | 7 +++++++ Practice/GrishchenkoA/5.2.py | 15 +++++++++++++++ Practice/GrishchenkoA/5.3.py | 0 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 Practice/GrishchenkoA/5.1.py create mode 100644 Practice/GrishchenkoA/5.2.py create mode 100644 Practice/GrishchenkoA/5.3.py diff --git a/Practice/GrishchenkoA/4.7.py b/Practice/GrishchenkoA/4.7.py index 680a356..5ba98ea 100644 --- a/Practice/GrishchenkoA/4.7.py +++ b/Practice/GrishchenkoA/4.7.py @@ -1,14 +1,16 @@ def decorator1(func): def equality(*args, **kwargs): print("===========") - func(*args, **kwargs) + res = func(*args, **kwargs) print("===========") - return func - return equality() + return res + return equality -def func1(): +@decorator1 +def func(): print("Привет") +func() + -decorator1(func1) diff --git a/Practice/GrishchenkoA/5.1.py b/Practice/GrishchenkoA/5.1.py new file mode 100644 index 0000000..6e96e03 --- /dev/null +++ b/Practice/GrishchenkoA/5.1.py @@ -0,0 +1,7 @@ +arr = [0, 3, 24, 2, 3, 7] +for i in range(0, len(arr)): + a = min(arr[i:]) + c = arr.index(a, i) + arr[c], arr[i] = arr[i], arr[c] +print(arr) + diff --git a/Practice/GrishchenkoA/5.2.py b/Practice/GrishchenkoA/5.2.py new file mode 100644 index 0000000..96b6633 --- /dev/null +++ b/Practice/GrishchenkoA/5.2.py @@ -0,0 +1,15 @@ +def repeat(lst): + lst_new = [] + for i in lst: + if not i in lst_new: + lst_new.append(i) + else: + print(i) + return i + + +lst_1 = [2, 3, 4, 5, 3, 2] +repeat(lst_1) + + + diff --git a/Practice/GrishchenkoA/5.3.py b/Practice/GrishchenkoA/5.3.py new file mode 100644 index 0000000..e69de29 From 9cc28c2dcf5ff9a6f280774868c1b257626785cb Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 20 Sep 2022 13:15:50 +0300 Subject: [PATCH 25/48] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0=205.1=20=D0=B8=205.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/5.1.py | 10 +++++++--- Practice/GrishchenkoA/5.2.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Practice/GrishchenkoA/5.1.py b/Practice/GrishchenkoA/5.1.py index 6e96e03..d9955ad 100644 --- a/Practice/GrishchenkoA/5.1.py +++ b/Practice/GrishchenkoA/5.1.py @@ -1,7 +1,11 @@ +def find_min_index(lst): + a = min(lst[i:]) + c = lst.index(a, i) + lst[c], lst[i] = lst[i], lst[c] + + arr = [0, 3, 24, 2, 3, 7] for i in range(0, len(arr)): - a = min(arr[i:]) - c = arr.index(a, i) - arr[c], arr[i] = arr[i], arr[c] + find_min_index(arr) print(arr) diff --git a/Practice/GrishchenkoA/5.2.py b/Practice/GrishchenkoA/5.2.py index 96b6633..4ecadbb 100644 --- a/Practice/GrishchenkoA/5.2.py +++ b/Practice/GrishchenkoA/5.2.py @@ -1,7 +1,7 @@ def repeat(lst): lst_new = [] for i in lst: - if not i in lst_new: + if not i in set(lst_new): lst_new.append(i) else: print(i) From eb128067240887afb7e9b41f33ae152b9700f8bc Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Wed, 21 Sep 2022 11:00:51 +0300 Subject: [PATCH 26/48] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0=205.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/5.2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Practice/GrishchenkoA/5.2.py b/Practice/GrishchenkoA/5.2.py index 4ecadbb..422cdd9 100644 --- a/Practice/GrishchenkoA/5.2.py +++ b/Practice/GrishchenkoA/5.2.py @@ -1,15 +1,15 @@ def repeat(lst): - lst_new = [] + set_new = set() for i in lst: - if not i in set(lst_new): - lst_new.append(i) + if not i in set_new: + set_new.add(i) else: print(i) return i -lst_1 = [2, 3, 4, 5, 3, 2] -repeat(lst_1) +lst_new = [2, 3, 4, 5, 3, 2] +repeat(lst_new) From 2090f32471a3e0f1ab7e0f1d1bd1745db700b3b1 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Wed, 21 Sep 2022 11:02:20 +0300 Subject: [PATCH 27/48] Version 1 --- Practice/GrishchenkoA/5.3.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Practice/GrishchenkoA/5.3.py b/Practice/GrishchenkoA/5.3.py index e69de29..aea0c51 100644 --- a/Practice/GrishchenkoA/5.3.py +++ b/Practice/GrishchenkoA/5.3.py @@ -0,0 +1,14 @@ +str = "Петров - 2 , Иванов - 5 , Сидоров - 4" +lst = list(str.split()) +dict_1 = {2: "неудовлетворительно", 3: "удовлетворительно", 4: "хорошо", 5: "отлично"} +for y, b in enumerate(lst): + for i, d in enumerate(dict_1): + if b.isdigit(): + if int(b) == d: + lst[y] = dict_1[d] +str_1 = "" +for i in lst: + print(str_1.join(i), end=" ") + + + From 1488e614da43bc22eaa4f606c727136791d9c2ad Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Wed, 21 Sep 2022 11:03:09 +0300 Subject: [PATCH 28/48] Version 1 --- Practice/GrishchenkoA/5.4.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Practice/GrishchenkoA/5.4.py diff --git a/Practice/GrishchenkoA/5.4.py b/Practice/GrishchenkoA/5.4.py new file mode 100644 index 0000000..29b5ff8 --- /dev/null +++ b/Practice/GrishchenkoA/5.4.py @@ -0,0 +1,16 @@ +def delete_column(lst, number): + for i, d in enumerate(lst): + for y, v in enumerate(d): + if number == int(v): + for k in range(len(lst_1)): + del lst_1[k][y] + + +lst_1 = [[1, 2, 3, 4], [7, 8, 9, 5], [5, 6, 7, 4], [1, 2, 9, 5]] +number_1 = int(input("Введите цифру: ")) +delete_column(lst_1, number_1) +print(lst_1) + + + + From d6b159fecf90ba03492e891670c9fa0c0f80cae0 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 26 Sep 2022 09:22:12 +0300 Subject: [PATCH 29/48] =?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=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=20=D1=83?= =?UTF-8?q?=D0=B4=D0=B0=D0=BB=D1=8F=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/5.4.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Practice/GrishchenkoA/5.4.py b/Practice/GrishchenkoA/5.4.py index 29b5ff8..a9bf9e7 100644 --- a/Practice/GrishchenkoA/5.4.py +++ b/Practice/GrishchenkoA/5.4.py @@ -2,15 +2,18 @@ def delete_column(lst, number): for i, d in enumerate(lst): for y, v in enumerate(d): if number == int(v): - for k in range(len(lst_1)): + for k in range(len(lst)): + del lst[k][y] + for y, v in enumerate(d): + if number == int(v): + for k in range(len(lst)): del lst_1[k][y] -lst_1 = [[1, 2, 3, 4], [7, 8, 9, 5], [5, 6, 7, 4], [1, 2, 9, 5]] +lst_1 = [[1, 2, 2, 4], [7, 8, 9, 5], [5, 6, 7, 4], [1, 2, 9, 5]] number_1 = int(input("Введите цифру: ")) delete_column(lst_1, number_1) print(lst_1) - From a920f238c4c29d79d752cb0715b9b5db343872b2 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 26 Sep 2022 09:34:24 +0300 Subject: [PATCH 30/48] =?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=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=20=D1=83?= =?UTF-8?q?=D0=B4=D0=B0=D0=BB=D1=8F=D0=B5=D1=82=20=D0=B8=20i=20=D1=83?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/5.4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Practice/GrishchenkoA/5.4.py b/Practice/GrishchenkoA/5.4.py index a9bf9e7..b38ab66 100644 --- a/Practice/GrishchenkoA/5.4.py +++ b/Practice/GrishchenkoA/5.4.py @@ -1,5 +1,5 @@ def delete_column(lst, number): - for i, d in enumerate(lst): + for d in lst: for y, v in enumerate(d): if number == int(v): for k in range(len(lst)): From 61c5ccf07a2b6f81167cb9dd088150364c2749df Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 26 Sep 2022 09:42:32 +0300 Subject: [PATCH 31/48] =?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 --- Practice/GrishchenkoA/5.3.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Practice/GrishchenkoA/5.3.py b/Practice/GrishchenkoA/5.3.py index aea0c51..713883b 100644 --- a/Practice/GrishchenkoA/5.3.py +++ b/Practice/GrishchenkoA/5.3.py @@ -1,11 +1,11 @@ -str = "Петров - 2 , Иванов - 5 , Сидоров - 4" -lst = list(str.split()) +str_new = "Петров - 2 , Иванов - 5 , Сидоров - 4" +lst = list(str_new.split()) dict_1 = {2: "неудовлетворительно", 3: "удовлетворительно", 4: "хорошо", 5: "отлично"} for y, b in enumerate(lst): - for i, d in enumerate(dict_1): - if b.isdigit(): - if int(b) == d: - lst[y] = dict_1[d] + if b.isdigit(): + b = int(b) + if b in dict_1: + lst[y] = dict_1[b] str_1 = "" for i in lst: print(str_1.join(i), end=" ") From e363ea17e8a857b9faf3c5484f4e4311e9f91dc8 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 26 Sep 2022 10:08:50 +0300 Subject: [PATCH 32/48] =?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 --- Practice/GrishchenkoA/4.5.py | 28 ++++++++++++++-------------- Practice/GrishchenkoA/5.1.py | 20 +++++++++++++++----- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Practice/GrishchenkoA/4.5.py b/Practice/GrishchenkoA/4.5.py index f6ec06c..810df3f 100644 --- a/Practice/GrishchenkoA/4.5.py +++ b/Practice/GrishchenkoA/4.5.py @@ -3,21 +3,21 @@ range = input("Введите диапазон чисел: ").split() hidden_numbers = random.randint(int(range[0]), int(range[1])) numbers_1 = input("Угадайте целое число: ") -if numbers_1.isdigit(): - while int(numbers_1) != hidden_numbers: - if not numbers_1.isdigit(): - print("Вы ввели нечисловой символ") - break +while True: + if not numbers_1.isdigit(): + print("Вы ввели нечисловой символ") + break + else: + numbers_1 = int(numbers_1) + if numbers_1 < hidden_numbers: + print("Загаданное число больше введенного") + elif numbers_1 > hidden_numbers: + print("Загаданное число меньше введенного") else: - numbers_1 = int(numbers_1) - if numbers_1 < hidden_numbers: - print("Загаданное число больше введенного") - elif numbers_1 > hidden_numbers: - print("Загаданное число меньше введенного") - numbers_1 = input("Угадайте целое число: ") - print("Вы угадали") -else: - print("Вы ввели нечисловой символ") + print("Вы угадали") + break + numbers_1 = input("Угадайте целое число: ") + diff --git a/Practice/GrishchenkoA/5.1.py b/Practice/GrishchenkoA/5.1.py index d9955ad..91b7356 100644 --- a/Practice/GrishchenkoA/5.1.py +++ b/Practice/GrishchenkoA/5.1.py @@ -1,11 +1,21 @@ def find_min_index(lst): - a = min(lst[i:]) - c = lst.index(a, i) - lst[c], lst[i] = lst[i], lst[c] + for i,d in enumerate(lst): + d = min(lst[i:]) + d, lst[i] = lst[i], d arr = [0, 3, 24, 2, 3, 7] -for i in range(0, len(arr)): - find_min_index(arr) +#for i in range(0, len(arr)): +find_min_index(arr) print(arr) +#def find_min_index(lst): + # a = min(lst[i:]) + # c = lst.index(a, i) + #lst[c], lst[i] = lst[i], lst[c] + + +#arr = [0, 3, 24, 2, 3, 7] +#for i in range(0, len(arr)): + # find_min_index(arr) +#print(arr) \ No newline at end of file From ba7b2afb1ff40f167baca6f2df247913a8c54bb3 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Thu, 29 Sep 2022 15:58:26 +0300 Subject: [PATCH 33/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=205=20=D0=B8=D0=B7=205=20=D0=BB=D0=B5=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=B8=201,2=20=D0=B8=D0=B7=206=20=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/5.5.py | 17 +++++++++++++ Practice/GrishchenkoA/6.1.py | 26 ++++++++++++++++++++ Practice/GrishchenkoA/6.2.py | 46 ++++++++++++++++++++++++++++++++++++ Practice/GrishchenkoA/6.3.py | 0 4 files changed, 89 insertions(+) create mode 100644 Practice/GrishchenkoA/5.5.py create mode 100644 Practice/GrishchenkoA/6.1.py create mode 100644 Practice/GrishchenkoA/6.2.py create mode 100644 Practice/GrishchenkoA/6.3.py diff --git a/Practice/GrishchenkoA/5.5.py b/Practice/GrishchenkoA/5.5.py new file mode 100644 index 0000000..1ed3cab --- /dev/null +++ b/Practice/GrishchenkoA/5.5.py @@ -0,0 +1,17 @@ +text1 = open("text1.txt", "r") +text_read = text1.read() +text1.close() +request = input("Введите tab, если нужно заменить табуляцию на 4 пробела, если наоборот введите four: ") +text1 = open("text1.txt", "w") +if request == "tab": + text1.write(text_read.replace('\t', ' ')) +elif request == "four": + text1.write(text_read.replace(' ', '\t')) +else: + print("Неизвестный запрос") +text1.close() + + + + + diff --git a/Practice/GrishchenkoA/6.1.py b/Practice/GrishchenkoA/6.1.py new file mode 100644 index 0000000..8d5f4e5 --- /dev/null +++ b/Practice/GrishchenkoA/6.1.py @@ -0,0 +1,26 @@ +class MyTanks(): + "Класс содержит виды танков c характеристиками" + color = "green" + + + def __init__(self, damage, rate_of_fire, ammunition, speed, strength): + self.damage = damage + self.rate_of_fire = rate_of_fire + self.ammunition = ammunition + self.speed = speed + self.strength = strength + + + def print_res(lst): + for i in lst: + print(i.__dict__) + + +su_76i = MyTanks(156, 16, 170, 50, 285) +su_85i = MyTanks(280, 14, 70, 50, 500) +k_91_pt = MyTanks(530, 7, 30, 52, 1600) +print(MyTanks.__doc__) +lst_tanks = [su_76i, su_85i, k_91_pt] +MyTanks.print_res(lst_tanks) + + diff --git a/Practice/GrishchenkoA/6.2.py b/Practice/GrishchenkoA/6.2.py new file mode 100644 index 0000000..fb3ee7d --- /dev/null +++ b/Practice/GrishchenkoA/6.2.py @@ -0,0 +1,46 @@ +class Duck: + color = "grey" + def __init__(self, name, weight): + self.name = name + self.weight = weight + + + @staticmethod + def say_Duck(): + print("Crack") + + + @classmethod + def color_duck(cls): + print(f"Цвет уток: {Duck.color}") + + + def __repr__(self): + print(f"Имя утки: {self.name}, вес утки: {self.weight} грамм") + + + def __lt__(self, other): + return {other.name} + + + def __ne__(self, other): + return self + + + def __add__(self, other): + return self + other + + + + +d1 = Duck("Billy", 700) +d2 = Duck("Willy", 900) +d3 = Duck("Dilly", 800) +d1.say_Duck() +Duck.color_duck() +d1.__repr__() +d2.__repr__() +d3.__repr__() +print(d1.__lt__(d2)) +print(d1.weight.__ne__(d2.weight)) +print(d1.weight.__add__(d3.weight)) diff --git a/Practice/GrishchenkoA/6.3.py b/Practice/GrishchenkoA/6.3.py new file mode 100644 index 0000000..e69de29 From 1fd6c15144a24176bff0586767c91d8e3be8c1c4 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 30 Sep 2022 18:04:09 +0300 Subject: [PATCH 34/48] =?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 --- Practice/GrishchenkoA/6.1.py | 4 ++-- Practice/GrishchenkoA/6.2.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Practice/GrishchenkoA/6.1.py b/Practice/GrishchenkoA/6.1.py index 8d5f4e5..ebe5f5d 100644 --- a/Practice/GrishchenkoA/6.1.py +++ b/Practice/GrishchenkoA/6.1.py @@ -1,4 +1,4 @@ -class MyTanks(): +class MyTanks: "Класс содержит виды танков c характеристиками" color = "green" @@ -10,7 +10,7 @@ def __init__(self, damage, rate_of_fire, ammunition, speed, strength): self.speed = speed self.strength = strength - + @staticmethod def print_res(lst): for i in lst: print(i.__dict__) diff --git a/Practice/GrishchenkoA/6.2.py b/Practice/GrishchenkoA/6.2.py index fb3ee7d..bdd6e4e 100644 --- a/Practice/GrishchenkoA/6.2.py +++ b/Practice/GrishchenkoA/6.2.py @@ -16,7 +16,7 @@ def color_duck(cls): def __repr__(self): - print(f"Имя утки: {self.name}, вес утки: {self.weight} грамм") + return f"Имя утки: {self.name}, вес утки: {self.weight} грамм" def __lt__(self, other): @@ -24,7 +24,7 @@ def __lt__(self, other): def __ne__(self, other): - return self + return self.weight != other.weight def __add__(self, other): @@ -38,9 +38,9 @@ def __add__(self, other): d3 = Duck("Dilly", 800) d1.say_Duck() Duck.color_duck() -d1.__repr__() -d2.__repr__() -d3.__repr__() -print(d1.__lt__(d2)) -print(d1.weight.__ne__(d2.weight)) +print(repr(d1)) +print(repr(d2)) +print(repr(d3)) +print(d2 < d3) +print(d1 != d2) print(d1.weight.__add__(d3.weight)) From 007feae9c27231161a017253c7bc7c9acfad9511 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 3 Oct 2022 13:26:38 +0300 Subject: [PATCH 35/48] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0=206.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/6.2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Practice/GrishchenkoA/6.2.py b/Practice/GrishchenkoA/6.2.py index bdd6e4e..2db82bd 100644 --- a/Practice/GrishchenkoA/6.2.py +++ b/Practice/GrishchenkoA/6.2.py @@ -28,7 +28,7 @@ def __ne__(self, other): def __add__(self, other): - return self + other + return self.weight + other.weight @@ -43,4 +43,4 @@ def __add__(self, other): print(repr(d3)) print(d2 < d3) print(d1 != d2) -print(d1.weight.__add__(d3.weight)) +print(f"Вес двух уток равен {d1 + d3} грамм") From 1c3f8bfd60ba2c5d7cc0d117cdc0377fbc5897f9 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Mon, 3 Oct 2022 14:26:26 +0300 Subject: [PATCH 36/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=206.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/6.3.py | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Practice/GrishchenkoA/6.3.py b/Practice/GrishchenkoA/6.3.py index e69de29..365e68b 100644 --- a/Practice/GrishchenkoA/6.3.py +++ b/Practice/GrishchenkoA/6.3.py @@ -0,0 +1,40 @@ +import tempfile +import os + + +class WrapStrToFile: + def __init__(self): + self.filepath = tempfile.mktemp() + + + @property + def content(self): + try: + with open(self.filepath, "r") as readfile: + file_1 = readfile.read() + return file_1 + except: + return "File doesn't exist" + + + @content.setter + def content(self, value): + try: + with open(self.filepath, "w") as writefile: + writefile.write(value) + except: + return "Error writing to file" + + + @content.deleter + def content(self): + os.remove(self.filepath) + + +wstf = WrapStrToFile() +print(wstf.content) +wstf.content = 'test str' +print(wstf.content) +wstf.content = 'text 2' +print(wstf.content) +del wstf.content From 97f4435d3c39c1b8a78ee8056911c86698e17688 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 11 Oct 2022 09:29:04 +0300 Subject: [PATCH 37/48] =?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 --- Practice/GrishchenkoA/6.2.py | 7 +++++-- Practice/GrishchenkoA/7.1.py | 0 Practice/GrishchenkoA/7.2.py | 0 Practice/GrishchenkoA/7.3.py | 0 Practice/GrishchenkoA/8.1.py | 0 Practice/GrishchenkoA/8.2.py | 0 Practice/GrishchenkoA/8.3.py | 0 Practice/GrishchenkoA/task 2.py | 0 8 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 Practice/GrishchenkoA/7.1.py create mode 100644 Practice/GrishchenkoA/7.2.py create mode 100644 Practice/GrishchenkoA/7.3.py create mode 100644 Practice/GrishchenkoA/8.1.py create mode 100644 Practice/GrishchenkoA/8.2.py create mode 100644 Practice/GrishchenkoA/8.3.py create mode 100644 Practice/GrishchenkoA/task 2.py diff --git a/Practice/GrishchenkoA/6.2.py b/Practice/GrishchenkoA/6.2.py index 2db82bd..be1a5a8 100644 --- a/Practice/GrishchenkoA/6.2.py +++ b/Practice/GrishchenkoA/6.2.py @@ -20,7 +20,10 @@ def __repr__(self): def __lt__(self, other): - return {other.name} + if self.weight < other.weight: + return other.name + else: + return self.name def __ne__(self, other): @@ -41,6 +44,6 @@ def __add__(self, other): print(repr(d1)) print(repr(d2)) print(repr(d3)) -print(d2 < d3) +print(f"Утка {d2 < d3} весит больше") print(d1 != d2) print(f"Вес двух уток равен {d1 + d3} грамм") diff --git a/Practice/GrishchenkoA/7.1.py b/Practice/GrishchenkoA/7.1.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/7.2.py b/Practice/GrishchenkoA/7.2.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/7.3.py b/Practice/GrishchenkoA/7.3.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/8.1.py b/Practice/GrishchenkoA/8.1.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/8.2.py b/Practice/GrishchenkoA/8.2.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/8.3.py b/Practice/GrishchenkoA/8.3.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/task 2.py b/Practice/GrishchenkoA/task 2.py new file mode 100644 index 0000000..e69de29 From be38b9ead110484628c9159503d7aeb28c6ca2d8 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 11 Oct 2022 14:07:46 +0300 Subject: [PATCH 38/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BA=207=20=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/7.1.py | 13 +++++++ Practice/GrishchenkoA/7.2.py | 22 ++++++++++++ Practice/GrishchenkoA/7.3.py | 68 ++++++++++++++++++++++++++++++++++++ Practice/GrishchenkoA/8.4.py | 0 4 files changed, 103 insertions(+) create mode 100644 Practice/GrishchenkoA/8.4.py diff --git a/Practice/GrishchenkoA/7.1.py b/Practice/GrishchenkoA/7.1.py index e69de29..43ab93b 100644 --- a/Practice/GrishchenkoA/7.1.py +++ b/Practice/GrishchenkoA/7.1.py @@ -0,0 +1,13 @@ +class Man: + def __init__(self, name): + self.name = name + + def solve_task(self): + print("I'm not ready yet") + + +Man_1 = Man("Ivan") +Man_1.solve_task() +print(Man_1.name) + + diff --git a/Practice/GrishchenkoA/7.2.py b/Practice/GrishchenkoA/7.2.py index e69de29..93cc560 100644 --- a/Practice/GrishchenkoA/7.2.py +++ b/Practice/GrishchenkoA/7.2.py @@ -0,0 +1,22 @@ +import random +import time + + +class Man: + def __init__(self, name): + self.name = name + + def solve_task(self): + print("I'm not ready yet") + + +class Pupil(Man): + def solve_task(self): + time_new = random.randint(3, 6) + res = time.sleep(time_new) + + +Pupill_1 = Pupil("Svetlana") +Pupill_1.solve_task() +print(Pupill_1.name) + diff --git a/Practice/GrishchenkoA/7.3.py b/Practice/GrishchenkoA/7.3.py index e69de29..0b714ee 100644 --- a/Practice/GrishchenkoA/7.3.py +++ b/Practice/GrishchenkoA/7.3.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +class ATM: + def __init__(self, cash): + self._cash = cash + + def get_cash(self): + return self._cash + + def set_cash(self, name): + self._cash = cash + + +class SimpleATM(ATM): + def deposit_cash(money): + if type(money) is float: + return money + else: + print("Неверно введена сумма") + def choice(self): + request = input("Выберите желаемую операцию: 1 - если хотите внести наличные, 2 - если хотите снять наличные: ") + if request == "1": + money = float(input("Введите сумму для внесения наличных на счет: ")) + self._cash = self._cash + money + print(f"На вашем счету теперь: {self._cash} рублей") + if request == "2": + money = float(input("Введите сумму, которую хотите снять со счета: ")) + if self._cash < money: + print("Недостаточно средств на счете") + else: + self._cash = self._cash - money + print(f"На вашем счету теперь: {self._cash} рублей") + return self._cash + + +class SuperATM(ATM): + def choice(self): + request = input("Выберите желаемую операцию: 1 - если хотите внести наличные, 2 - если хотите снять наличные, 3 - хотите оплатить онлайн: ") + if request == "1": + money = float(input("Введите сумму для внесения наличных на счет: ")) + self._cash = self._cash + money + print(f"На вашем счету теперь: {self._cash} рублей") + if request == "2": + money = float(input("Введите сумму, которую хотите снять со счета: ")) + if self._cash < money: + print("Недостаточно средств на счете") + else: + self._cash = self._cash - money + print(f"На вашем счету теперь: {self._cash} рублей") + if request == "3": + money = float(input("Введите сумму для оплаты онлайн: ")) + if self._cash < money: + print("Недостаточно средств на счете") + else: + self._cash = self._cash - money + print(f"На вашем счету теперь: {self._cash} рублей") + return self._cash + + +# person_1 = SimpleATM(50000) +# person_1.choice() + +person_2 = SuperATM(52000) +person_2.choice() + + + + + diff --git a/Practice/GrishchenkoA/8.4.py b/Practice/GrishchenkoA/8.4.py new file mode 100644 index 0000000..e69de29 From cb91fa8803d93f557a97f467da3fa876de59bed1 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 11 Oct 2022 14:10:14 +0300 Subject: [PATCH 39/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BA=208=20=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/8.1.py | 33 +++++++++++++++++++++++++++++++++ Practice/GrishchenkoA/8.2.py | 14 ++++++++++++++ Practice/GrishchenkoA/8.3.py | 14 ++++++++++++++ Practice/GrishchenkoA/8.4.py | 18 ++++++++++++++++++ 4 files changed, 79 insertions(+) diff --git a/Practice/GrishchenkoA/8.1.py b/Practice/GrishchenkoA/8.1.py index e69de29..338999c 100644 --- a/Practice/GrishchenkoA/8.1.py +++ b/Practice/GrishchenkoA/8.1.py @@ -0,0 +1,33 @@ + +class IterRead: + def __init__(self, file_new, symbol): + self.file_new = file_new + self.symbol = symbol + self.ind = 0 + + + def __iter__(self): + return self + + def __next__(self): + try: + with open(self.file_new, "r") as file: + text = "" + while self.ind != -1: + file.seek(self.ind) + txt = file.read(1) + if txt != self.symbol: + text += txt + else: + self.ind = file.tell() + return text + self.ind += 1 + # else: + # raise StopIteration + except: + print("****") + +c = IterRead("text8.txt", "~") +for i in c: + print(i) + print("===============") \ No newline at end of file diff --git a/Practice/GrishchenkoA/8.2.py b/Practice/GrishchenkoA/8.2.py index e69de29..809338e 100644 --- a/Practice/GrishchenkoA/8.2.py +++ b/Practice/GrishchenkoA/8.2.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +def read_line(file): + try: + with open(file, "r") as f: + for stroka in f: + yield stroka + except: + print("Ошибка при чтении файла") + + + +for i in read_line("text4.txt"): + print(i) + print("=======") \ No newline at end of file diff --git a/Practice/GrishchenkoA/8.3.py b/Practice/GrishchenkoA/8.3.py index e69de29..0b2b93c 100644 --- a/Practice/GrishchenkoA/8.3.py +++ b/Practice/GrishchenkoA/8.3.py @@ -0,0 +1,14 @@ +import time + +class Manager_Time: + def __enter__(self): + self.start = time.time() + + def __exit__(self, exc_type, exc_val, exc_tb): + self.stop = time.time() - self.start + print(f"Время выполнения программы заняло: {self.stop} секунд") + + +with Manager_Time(): + for i in range(100000): + i += i \ No newline at end of file diff --git a/Practice/GrishchenkoA/8.4.py b/Practice/GrishchenkoA/8.4.py index e69de29..b472856 100644 --- a/Practice/GrishchenkoA/8.4.py +++ b/Practice/GrishchenkoA/8.4.py @@ -0,0 +1,18 @@ +import itertools + +t = ([1, 2, 3], [4, 5], [6, 7]) +lst = [] +f = itertools.chain(t) +for i in f: + lst += i +print(lst) + +c = ['hello', 'i', 'write', 'cool', 'code'] +l = itertools.filterfalse(lambda x: len(x) < 5, c) +lst1 = list(l) +print(lst1) + +d = 'password' +v = itertools.combinations_with_replacement(d, 4) +print(list(v)) + From 7a9d0e0abed4d0d3e3d334a4d20e1ecc3f5abfad Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Tue, 11 Oct 2022 14:17:05 +0300 Subject: [PATCH 40/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BA=20=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B8=208?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/8.1.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Practice/GrishchenkoA/8.1.py b/Practice/GrishchenkoA/8.1.py index 338999c..5146571 100644 --- a/Practice/GrishchenkoA/8.1.py +++ b/Practice/GrishchenkoA/8.1.py @@ -1,4 +1,4 @@ - +# -*- coding: utf-8 -*- class IterRead: def __init__(self, file_new, symbol): self.file_new = file_new @@ -22,12 +22,10 @@ def __next__(self): self.ind = file.tell() return text self.ind += 1 - # else: - # raise StopIteration except: - print("****") + return "Файл не существует" -c = IterRead("text8.txt", "~") +c = IterRead("text4.txt", "~") for i in c: print(i) print("===============") \ No newline at end of file From d23a711160bfc8e2ab540c0af718c6b74333c63d Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 14 Oct 2022 20:31:24 +0300 Subject: [PATCH 41/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=201,2=20=D0=BA=20=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/10.1.py | 0 Practice/GrishchenkoA/10.2.py | 0 Practice/GrishchenkoA/10.3.py | 0 Practice/GrishchenkoA/9.1.py | 0 Practice/GrishchenkoA/9.2.py | 0 Practice/GrishchenkoA/9.4.2.py | 0 Practice/GrishchenkoA/9.4.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Practice/GrishchenkoA/10.1.py create mode 100644 Practice/GrishchenkoA/10.2.py create mode 100644 Practice/GrishchenkoA/10.3.py create mode 100644 Practice/GrishchenkoA/9.1.py create mode 100644 Practice/GrishchenkoA/9.2.py create mode 100644 Practice/GrishchenkoA/9.4.2.py create mode 100644 Practice/GrishchenkoA/9.4.py diff --git a/Practice/GrishchenkoA/10.1.py b/Practice/GrishchenkoA/10.1.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/10.2.py b/Practice/GrishchenkoA/10.2.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/10.3.py b/Practice/GrishchenkoA/10.3.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/9.1.py b/Practice/GrishchenkoA/9.1.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/9.2.py b/Practice/GrishchenkoA/9.2.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/9.4.2.py b/Practice/GrishchenkoA/9.4.2.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/9.4.py b/Practice/GrishchenkoA/9.4.py new file mode 100644 index 0000000..e69de29 From 8c09263f0ab2aa077994fa3ce8db67fe71c9358b Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 14 Oct 2022 20:45:07 +0300 Subject: [PATCH 42/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=201,2=20=D0=BA=20=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/9.1.py | 26 ++++++++++++++++++++++++++ Practice/GrishchenkoA/9.2.py | 14 ++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/Practice/GrishchenkoA/9.1.py b/Practice/GrishchenkoA/9.1.py index e69de29..55e99e2 100644 --- a/Practice/GrishchenkoA/9.1.py +++ b/Practice/GrishchenkoA/9.1.py @@ -0,0 +1,26 @@ +#-*- coding: utf-8 -*- +import re + +st = re.compile(r"git [a-z]{3,4} \Z|git [a-z]{4,8} \W+[a-z]{1,3}\W+[a-z]{2,8}.[a-z]{6}|git [a-z]{4,8}.{55}|git [a-z]{3,4} [a-z]{6}.?[a-z]{2,4}|git [a-z]{3,4}") +with open(r"../README.md", encoding="utf") as f: + txt = f.read() + +res1 = re.findall(st, txt) +print(res1) + + + + + + + + +#git clone https://github.com/IlyaOrlov/PythonCourse2.0_August22.git "git [a-z]{4,8}\W{55}git +#git checkout -b my_branch "git [a-z]{4,8} \W+[a-z]{1,3}\W+[a-z]{2,8}.[a-z]{6}" +#git push --set-upstream origin my_branch git [a-z]{4,8} \W+[a-z]{1,3}\W+[a-z]{2,8}.[a-z]{6} my_branch" +#git commit -m "Любой разумный комментарий к сделанным изменениям" r"git [a-z]{4,8} \W+[a-z]{1,3}\W" +#git@github.com:IlyaOrlov/PythonCourse2.0_August22.git r"git.?[a-z]{6}.[a-z]{3}.{39}" +#git push r"git [a-z]{3,4} +#git add +#git add mytest.py r"git [a-z]{3,4} [a-z]{6}.?[a-z]{2,4} +#git pull origin main r"git \ No newline at end of file diff --git a/Practice/GrishchenkoA/9.2.py b/Practice/GrishchenkoA/9.2.py index e69de29..82465d9 100644 --- a/Practice/GrishchenkoA/9.2.py +++ b/Practice/GrishchenkoA/9.2.py @@ -0,0 +1,14 @@ +#-*- coding: utf-8 -*- +import datetime as dt + +def search_days(start, stop): + start = start.split('.') + stop = stop.split('.') + start_day = dt.date(int(start[2]), int(start[1]), int(start[0])) + stop_day = dt.date(int(stop[2]), int(stop[1]), int(stop[0])) + day = stop_day - start_day + work_day = day/7*5 + print(work_day) + + +search_days("01.01.2020", "01.02.2020") \ No newline at end of file From d9bb32cf3527608deb045de6f35d4d395a8287ca Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 14 Oct 2022 20:46:18 +0300 Subject: [PATCH 43/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=201,2=20=D0=BA=20=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/10.1.py | 4 ++++ Practice/GrishchenkoA/10.2.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Practice/GrishchenkoA/10.1.py b/Practice/GrishchenkoA/10.1.py index e69de29..fec6739 100644 --- a/Practice/GrishchenkoA/10.1.py +++ b/Practice/GrishchenkoA/10.1.py @@ -0,0 +1,4 @@ +lst = ["10", "5", "a", "3", "b"] +lst1 = [x**2 for z in lst if z.isdigit() and (x := int(z))%5 == 0] +print(lst1) + diff --git a/Practice/GrishchenkoA/10.2.py b/Practice/GrishchenkoA/10.2.py index e69de29..d1af75f 100644 --- a/Practice/GrishchenkoA/10.2.py +++ b/Practice/GrishchenkoA/10.2.py @@ -0,0 +1,17 @@ +#-*- coding: utf-8 -*- +import random + +hello = ["Привет!", "Здравствуйте!", "Добрый день!"] +mood = ["Хорошо!", "Так себе", "Что-то не очень хорошо"] +weather = ["Сегодня ветренно", "Сегодня солнечно", "Дождь"] + +while True: + match input('Что Вы хотели спросить: '): + case "Привет": + print(random.choice(hello)) + case "Как дела?": + print(random.choice(mood)) + case "Какая сегодня погода": + print(random.choice(weather)) + case _: + print("Вопрос некорректен, попробуйте сформулировать его по-другому") From 837c45c5ed0e9ee07ff70436972ba471af70ffcb Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 14 Oct 2022 20:56:44 +0300 Subject: [PATCH 44/48] =?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 --- Practice/GrishchenkoA/7.2.py | 3 ++- Practice/GrishchenkoA/7.3.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Practice/GrishchenkoA/7.2.py b/Practice/GrishchenkoA/7.2.py index 93cc560..b01a789 100644 --- a/Practice/GrishchenkoA/7.2.py +++ b/Practice/GrishchenkoA/7.2.py @@ -17,6 +17,7 @@ def solve_task(self): Pupill_1 = Pupil("Svetlana") -Pupill_1.solve_task() +Man_1 = Man("Petr") +Man_1.solve_task() print(Pupill_1.name) diff --git a/Practice/GrishchenkoA/7.3.py b/Practice/GrishchenkoA/7.3.py index 0b714ee..23879d6 100644 --- a/Practice/GrishchenkoA/7.3.py +++ b/Practice/GrishchenkoA/7.3.py @@ -6,7 +6,7 @@ def __init__(self, cash): def get_cash(self): return self._cash - def set_cash(self, name): + def set_cash(self): self._cash = cash @@ -16,6 +16,7 @@ def deposit_cash(money): return money else: print("Неверно введена сумма") + def choice(self): request = input("Выберите желаемую операцию: 1 - если хотите внести наличные, 2 - если хотите снять наличные: ") if request == "1": @@ -35,10 +36,12 @@ def choice(self): class SuperATM(ATM): def choice(self): request = input("Выберите желаемую операцию: 1 - если хотите внести наличные, 2 - если хотите снять наличные, 3 - хотите оплатить онлайн: ") + if request == "1": money = float(input("Введите сумму для внесения наличных на счет: ")) self._cash = self._cash + money print(f"На вашем счету теперь: {self._cash} рублей") + if request == "2": money = float(input("Введите сумму, которую хотите снять со счета: ")) if self._cash < money: @@ -46,6 +49,7 @@ def choice(self): else: self._cash = self._cash - money print(f"На вашем счету теперь: {self._cash} рублей") + if request == "3": money = float(input("Введите сумму для оплаты онлайн: ")) if self._cash < money: From fefbdf57065bbc49dbaf9413dbd4b07fc5be5d89 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 14 Oct 2022 21:13:44 +0300 Subject: [PATCH 45/48] =?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 --- Practice/GrishchenkoA/8.1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Practice/GrishchenkoA/8.1.py b/Practice/GrishchenkoA/8.1.py index 5146571..b3dbb46 100644 --- a/Practice/GrishchenkoA/8.1.py +++ b/Practice/GrishchenkoA/8.1.py @@ -22,10 +22,12 @@ def __next__(self): self.ind = file.tell() return text self.ind += 1 + if txt == "": + raise StopIteration except: return "Файл не существует" -c = IterRead("text4.txt", "~") +c = IterRead("text1.txt", "~") for i in c: print(i) print("===============") \ No newline at end of file From 2311458568bc7e3c2c5ff6e5ce8649a893c273a9 Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Fri, 14 Oct 2022 21:15:46 +0300 Subject: [PATCH 46/48] =?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 --- Practice/GrishchenkoA/8.3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Practice/GrishchenkoA/8.3.py b/Practice/GrishchenkoA/8.3.py index 0b2b93c..dc60a5c 100644 --- a/Practice/GrishchenkoA/8.3.py +++ b/Practice/GrishchenkoA/8.3.py @@ -1,6 +1,6 @@ import time -class Manager_Time: +class ManagerTime: def __enter__(self): self.start = time.time() @@ -9,6 +9,6 @@ def __exit__(self, exc_type, exc_val, exc_tb): print(f"Время выполнения программы заняло: {self.stop} секунд") -with Manager_Time(): +with ManagerTime(): for i in range(100000): i += i \ No newline at end of file From 1b713bab1684520f52fdb8b25da5eb78137944fa Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Thu, 20 Oct 2022 11:04:08 +0300 Subject: [PATCH 47/48] =?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 --- Practice/GrishchenkoA/11.1.py | 0 Practice/GrishchenkoA/11.2.py | 0 Practice/GrishchenkoA/11.3.py | 0 Practice/GrishchenkoA/12.1 k.py | 0 Practice/GrishchenkoA/12.1.py | 0 Practice/GrishchenkoA/7.2.py | 4 ++-- Practice/GrishchenkoA/8.1.py | 40 ++++++++++++++++----------------- Practice/GrishchenkoA/9.2.py | 20 ++++++++++------- Practice/GrishchenkoA/9.3.py | 0 Practice/GrishchenkoA/exam.py | 0 10 files changed, 34 insertions(+), 30 deletions(-) create mode 100644 Practice/GrishchenkoA/11.1.py create mode 100644 Practice/GrishchenkoA/11.2.py create mode 100644 Practice/GrishchenkoA/11.3.py create mode 100644 Practice/GrishchenkoA/12.1 k.py create mode 100644 Practice/GrishchenkoA/12.1.py create mode 100644 Practice/GrishchenkoA/9.3.py create mode 100644 Practice/GrishchenkoA/exam.py diff --git a/Practice/GrishchenkoA/11.1.py b/Practice/GrishchenkoA/11.1.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/11.2.py b/Practice/GrishchenkoA/11.2.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/11.3.py b/Practice/GrishchenkoA/11.3.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/12.1 k.py b/Practice/GrishchenkoA/12.1 k.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/12.1.py b/Practice/GrishchenkoA/12.1.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/7.2.py b/Practice/GrishchenkoA/7.2.py index b01a789..b0e8ace 100644 --- a/Practice/GrishchenkoA/7.2.py +++ b/Practice/GrishchenkoA/7.2.py @@ -14,10 +14,10 @@ class Pupil(Man): def solve_task(self): time_new = random.randint(3, 6) res = time.sleep(time_new) + super().solve_task() Pupill_1 = Pupil("Svetlana") Man_1 = Man("Petr") -Man_1.solve_task() -print(Pupill_1.name) +Pupill_1.solve_task() diff --git a/Practice/GrishchenkoA/8.1.py b/Practice/GrishchenkoA/8.1.py index b3dbb46..4d51d22 100644 --- a/Practice/GrishchenkoA/8.1.py +++ b/Practice/GrishchenkoA/8.1.py @@ -10,24 +10,24 @@ def __iter__(self): return self def __next__(self): - try: - with open(self.file_new, "r") as file: - text = "" - while self.ind != -1: - file.seek(self.ind) - txt = file.read(1) - if txt != self.symbol: - text += txt - else: - self.ind = file.tell() - return text - self.ind += 1 - if txt == "": - raise StopIteration - except: - return "Файл не существует" + text = "" + while self.ind != -1: + file.seek(self.ind) + txt = file.read(1) + if txt != self.symbol: + text += txt + else: + self.ind = file.tell() + return text + self.ind += 1 + if txt == "": + raise StopIteration -c = IterRead("text1.txt", "~") -for i in c: - print(i) - print("===============") \ No newline at end of file + def __del__(self): + self.file_new() + + +with open("text1.txt", "r") as file: + for i in IterRead(file, "~"): + print(i) + print("===============") \ No newline at end of file diff --git a/Practice/GrishchenkoA/9.2.py b/Practice/GrishchenkoA/9.2.py index 82465d9..9f3c8d1 100644 --- a/Practice/GrishchenkoA/9.2.py +++ b/Practice/GrishchenkoA/9.2.py @@ -1,14 +1,18 @@ -#-*- coding: utf-8 -*- +# #-*- coding: utf-8 -*- import datetime as dt def search_days(start, stop): - start = start.split('.') - stop = stop.split('.') - start_day = dt.date(int(start[2]), int(start[1]), int(start[0])) - stop_day = dt.date(int(stop[2]), int(stop[1]), int(stop[0])) - day = stop_day - start_day - work_day = day/7*5 + + day = (start + dt.timedelta(x) for x in range((stop - start).days + 1)) + work_day = sum(1 for day in day if day.weekday() < 5) print(work_day) +start_day = dt.date(2020,1,1) +stop_day = dt.date(2020,2,1) + +search_days(start_day, stop_day) + + + + -search_days("01.01.2020", "01.02.2020") \ No newline at end of file diff --git a/Practice/GrishchenkoA/9.3.py b/Practice/GrishchenkoA/9.3.py new file mode 100644 index 0000000..e69de29 diff --git a/Practice/GrishchenkoA/exam.py b/Practice/GrishchenkoA/exam.py new file mode 100644 index 0000000..e69de29 From 679b66cbb820590bfeeb537b14bcb39d47af6bda Mon Sep 17 00:00:00 2001 From: AleksandraG88 Date: Thu, 20 Oct 2022 11:26:17 +0300 Subject: [PATCH 48/48] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=2011.1,=2011.2,=2012.1(=D1=81=D0=B5=D1=80=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=20=D0=B8=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/GrishchenkoA/11.1.py | 63 +++++++++++++++++++++++++++++++++++ Practice/GrishchenkoA/11.2.py | 28 ++++++++++++++++ Practice/GrishchenkoA/12.1.py | 26 +++++++++++++++ 3 files changed, 117 insertions(+) diff --git a/Practice/GrishchenkoA/11.1.py b/Practice/GrishchenkoA/11.1.py index e69de29..aadc1d5 100644 --- a/Practice/GrishchenkoA/11.1.py +++ b/Practice/GrishchenkoA/11.1.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- + +import time +import threading +import multiprocessing + +def find_primes(*args): + if len(args) == 1: + start = 3 + end = args[0] + else: + start = args[0] + end = args[1] + + lst = [] + for i in range(start, end + 1): + if i > 1: + for y in range(2, i): + if i % y == 0: + break + else: + lst.append(i) + return lst + +if __name__ == "__main__": + lst_time = [] + start = time.perf_counter() + find_primes(10000) + find_primes(10001, 20000) + find_primes(20001, 30000) + + lst_time.append(time.perf_counter() - start) + print(f"Общее время обычного расчета занял в секундах: {lst_time}") + + start = time.perf_counter() # считаем что-то много раз с разными параметрами + lst_time1 = [] + thr1 = threading.Thread(target=find_primes, args=(10000,)) + thr2 = threading.Thread(target=find_primes, args=(10001, 20000)) + thr3 = threading.Thread(target=find_primes, args=(20001, 30000)) + thr1.start() # если 'забыть' выполнить start, то будет ошибка RuntimeError: cannot join thread before it is started + thr2.start() + thr3.start() + thr1.join() # если 'забыть' выполнить join, то ошибки не будет, но выполнится только один поток + thr2.join() + thr3.join() + lst_time1.append(time.perf_counter() - start) + print(f"Общее время расчета через многопоточность занял в секундах: {lst_time1}") + + start = time.perf_counter() + lst_time2 = [] + p1 = multiprocessing.Process(target=find_primes, args=(10000,)) + p2 = multiprocessing.Process(target=find_primes, args=(10001, 20000)) + p3 = multiprocessing.Process(target=find_primes, args=(20001, 30000)) + p1.start() # если 'забыть' выполнить start, то будет ошибка AssertionError: can only join a started process + p2.start() + p3.start() + p1.join() # если 'забыть' выполнить join, то ошибки не будет, но выполнится только один процесс + p2.join() + p3.join() + lst_time2.append(time.perf_counter() - start) + print(f"Общее время расчета через многопроцессорность занял в секундах: {lst_time2}") + +# Быстрее всего данная задача решается через многопоточность \ No newline at end of file diff --git a/Practice/GrishchenkoA/11.2.py b/Practice/GrishchenkoA/11.2.py index e69de29..5fd0b59 100644 --- a/Practice/GrishchenkoA/11.2.py +++ b/Practice/GrishchenkoA/11.2.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from multiprocessing import Pool + +def addition(data): + t = data[0] + match t: + case int(t): + res = 0 + for y in data: + res += y + case str(t): + res = "" + for y in data: + res += y + case list(t): + res = [] + for y in data: + res += y + return res + + + +if __name__ == '__main__': + data = ([1, 2, 4], [[1, 2], [4, 7], [9, 0]], ["Hello", "world"]) + pool = Pool(processes=3) + res = pool.map(addition, data) + print(res) + diff --git a/Practice/GrishchenkoA/12.1.py b/Practice/GrishchenkoA/12.1.py index e69de29..4d73c07 100644 --- a/Practice/GrishchenkoA/12.1.py +++ b/Practice/GrishchenkoA/12.1.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +import socket +import pickle + + +s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +host = '192.168.1.35' +port = 64698 +s.bind((host, port)) +s.listen(2) +conn, addr = s.accept() +print('Server got connection from {}'.format(addr)) +while True: + data = conn.recv(1024) + if not data: + break + data1 = pickle.loads(data) + d = {"house": "дом", "car": "машина", "three": "дерево", "cat": "кошка", "apple": "яблоко"} + c = d.keys() + a = [] + for i in c: + for y in data1: + if y == i: + a.append(d[i]) + conn.send(pickle.dumps(a)) +conn.close()