From 1791dff88e4279e88c0e7008560fb3f8c8d280d4 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 13 Sep 2022 22:09:48 +0300 Subject: [PATCH 01/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_2.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Practice/MoiseevD/lesson_4_2.py diff --git a/Practice/MoiseevD/lesson_4_2.py b/Practice/MoiseevD/lesson_4_2.py new file mode 100644 index 0000000..8b89a2b --- /dev/null +++ b/Practice/MoiseevD/lesson_4_2.py @@ -0,0 +1,5 @@ +s = input('Введите пятизначное число: ') +i = 0 +while i < len(s): + i += 1 + print(f'{i} Цифра равна: {s[i-1]}') \ No newline at end of file From 8c7b94681efbbef7aeada48ad3b49ac191d6c9d6 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 15 Sep 2022 19:41:04 +0300 Subject: [PATCH 02/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_1.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Practice/MoiseevD/lesson_4_1.py diff --git a/Practice/MoiseevD/lesson_4_1.py b/Practice/MoiseevD/lesson_4_1.py new file mode 100644 index 0000000..4c42fc3 --- /dev/null +++ b/Practice/MoiseevD/lesson_4_1.py @@ -0,0 +1,11 @@ +i = 0 +while i < 100: + i += 1 + if i % 15 == 0: + print('FizzBizz') + elif i % 5 == 0: + print('Bizz') + elif i % 3 == 0: + print('Fizz') + else: + print(i) \ No newline at end of file From c63abade3640369b41842117cf3a329db09ca3a0 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 15 Sep 2022 19:43:47 +0300 Subject: [PATCH 03/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_3.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Practice/MoiseevD/lesson_4_3.py diff --git a/Practice/MoiseevD/lesson_4_3.py b/Practice/MoiseevD/lesson_4_3.py new file mode 100644 index 0000000..4b38be5 --- /dev/null +++ b/Practice/MoiseevD/lesson_4_3.py @@ -0,0 +1,14 @@ +str_num = "" + +while True: + s = input('Введите число: ') + + if s.lower() == 'stop': + break + + if not s.isdecimal(): + print('--Введите только число--') + continue + + str_num += s + print(str_num) From 71db7a35cdaed32c7c80eb6a27b59c4fc41b73a4 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 15 Sep 2022 22:22:49 +0300 Subject: [PATCH 04/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_4.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Practice/MoiseevD/lesson_4_4.py diff --git a/Practice/MoiseevD/lesson_4_4.py b/Practice/MoiseevD/lesson_4_4.py new file mode 100644 index 0000000..78b13f2 --- /dev/null +++ b/Practice/MoiseevD/lesson_4_4.py @@ -0,0 +1,12 @@ +import random + + +while True: + question = input('Задайте вопрос: ') + s = ('Ты сам-то понял, что написал?', 'Аргументируй', 'И?') + answers = random.choice(s) + print(answers) + + if question.lower() == 'хватит': + print('Выход из программы') + break From 797129d8d0a5b83031fe5e8045107978444f5168 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 16 Sep 2022 19:29:00 +0300 Subject: [PATCH 05/18] =?UTF-8?q?=D0=B2=D1=8B=D0=BD=D0=B5=D0=B7=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=83=D1=8E=20s=20?= =?UTF-8?q?=D0=B8=D0=B7=20while?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_4.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Practice/MoiseevD/lesson_4_4.py b/Practice/MoiseevD/lesson_4_4.py index 78b13f2..24f620a 100644 --- a/Practice/MoiseevD/lesson_4_4.py +++ b/Practice/MoiseevD/lesson_4_4.py @@ -1,12 +1,14 @@ import random +s = ('Ты сам-то понял, что написал?', 'Аргументируй', 'И?') + while True: - question = input('Задайте вопрос: ') - s = ('Ты сам-то понял, что написал?', 'Аргументируй', 'И?') answers = random.choice(s) - print(answers) + question = input('Задайте вопрос: ') if question.lower() == 'хватит': - print('Выход из программы') + print('---Выход из программы---') break + else: + print(answers) From 1ddcaeec777ec16a69f6e48b5a413324feca177f Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 16 Sep 2022 19:43:55 +0300 Subject: [PATCH 06/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_6.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Practice/MoiseevD/lesson_4_6.py diff --git a/Practice/MoiseevD/lesson_4_6.py b/Practice/MoiseevD/lesson_4_6.py new file mode 100644 index 0000000..ac4793c --- /dev/null +++ b/Practice/MoiseevD/lesson_4_6.py @@ -0,0 +1,13 @@ +def max_item(a, b): + print(max(a, b)) + + +def max_ret(a, b): + return max(a, b) + + +high = int(input('Введите первое число: ')) +low = int(input('Введите второе число: ')) +max_item(high, low) +b = max_ret(high, low) +print(b) \ No newline at end of file From 32dfe8824a98e9c563f1448c15d03fe6c94df9d8 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 16 Sep 2022 22:23:55 +0300 Subject: [PATCH 07/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_5.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Practice/MoiseevD/lesson_4_5.py diff --git a/Practice/MoiseevD/lesson_4_5.py b/Practice/MoiseevD/lesson_4_5.py new file mode 100644 index 0000000..47c4e33 --- /dev/null +++ b/Practice/MoiseevD/lesson_4_5.py @@ -0,0 +1,20 @@ +import random + + +s = int(input('Введите нижний диапазон: ')) +s1 = int(input('Введите верхний диапазон: ')) +num = random.randint(s, s1) + +while True: + guess_str = input('Угадайте число: ') + if not guess_str.isdecimal(): + print('---Завершение---') + break + guess = int(guess_str) + if guess == num: + print('---Вы угадали---') + break + elif guess < num: + print(' Ваше число меньше ') + elif guess > num: + print(' Ваше число больше ') From 4fbd3364240d97312be786adae76fd30114d8489 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 16 Sep 2022 23:23:13 +0300 Subject: [PATCH 08/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_8.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Practice/MoiseevD/lesson_4_8.py diff --git a/Practice/MoiseevD/lesson_4_8.py b/Practice/MoiseevD/lesson_4_8.py new file mode 100644 index 0000000..37c5c4e --- /dev/null +++ b/Practice/MoiseevD/lesson_4_8.py @@ -0,0 +1,28 @@ +import random + + +game_list = ["камень", "ножницы", "бумага"] +game = random.choice(game_list) + +while True: + s = input('Введите слово "КАМЕНЬ", "НОЖНИЦЫ", или "БУМАГА": ') + if s.lower() == 'камень' and game == game_list[0]: + print(f'---{game}---\n Ничья') + elif s.lower() == 'камень' and game == game_list[1]: + print(f'---{game}---\n Вы выиграли') + elif s.lower() == 'камень' and game == game_list[2]: + print(f'---{game}---\n Вы проиграли') + + elif s.lower() == 'ножницы' and game == game_list[0]: + print(f'---{game}---\n Вы проиграли') + elif s.lower() == 'ножницы' and game == game_list[1]: + print(f'---{game}---\n Ничья') + elif s.lower() == 'ножницы' and game == game_list[2]: + print(f'---{game}---\n Вы выиграли') + + elif s.lower() == 'бумага' and game == game_list[0]: + print(f'---{game}---\n Вы выиграли') + elif s.lower() == 'бумага' and game == game_list[1]: + print(f'---{game}---\n Вы проиграли') + elif s.lower() == 'бумага' and game == game_list[2]: + print(f'---{game}---\n Ничья') \ No newline at end of file From 4be8562ede2b06f5e588a53cb777794ec988e1b2 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 17 Sep 2022 16:58:26 +0300 Subject: [PATCH 09/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_7.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Practice/MoiseevD/lesson_4_7.py diff --git a/Practice/MoiseevD/lesson_4_7.py b/Practice/MoiseevD/lesson_4_7.py new file mode 100644 index 0000000..1f92955 --- /dev/null +++ b/Practice/MoiseevD/lesson_4_7.py @@ -0,0 +1,14 @@ +def decor_start(start): + def decor_finish(*args, **kwargs): + res = start(*args, **kwargs) + return res + return decor_finish + + +@decor_start +def start_finish(start): + print(f'После запуска функции {start}') + +line = "============" +print(f'До запуска функции {line}') +start_finish(line) From 44a86f6bafdaded2ec0f318da4773ed0f0a424e3 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 30 Sep 2022 21:57:05 +0300 Subject: [PATCH 10/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_5_1.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Practice/MoiseevD/lesson_5_1.py diff --git a/Practice/MoiseevD/lesson_5_1.py b/Practice/MoiseevD/lesson_5_1.py new file mode 100644 index 0000000..ff03bde --- /dev/null +++ b/Practice/MoiseevD/lesson_5_1.py @@ -0,0 +1,23 @@ +def current_index(arr, idx): + idx_min = idx + #i = idx # Вариант с циклом while + # while i < len(arr): + # if arr[i] < arr[idx_min]: + # idx_min = i + # i += 1 + for i in range(idx, len(arr)): # Вариант с циклом for + if arr[i] < arr[idx_min]: + idx_min = i + return idx_min + + +def min_element(elm): + for i in range(len(elm)): + cur_idx = current_index(elm, i) + elm[cur_idx], elm[i] = elm[i], elm[cur_idx] + return elm + + +a = [0, 3, 24, 2, 3, 7] +res = min_element(a) +print(res) From 22126d89a338b16a48466f86b18edcc61d6c15bd Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 5 Oct 2022 21:30:21 +0300 Subject: [PATCH 11/18] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_3.py | 4 +-- Practice/MoiseevD/lesson_4_4.py | 2 +- Practice/MoiseevD/lesson_4_7.py | 10 ++++--- Practice/MoiseevD/lesson_4_8.py | 49 +++++++++++++++++++-------------- Practice/MoiseevD/lesson_5_1.py | 8 ++++-- 5 files changed, 43 insertions(+), 30 deletions(-) diff --git a/Practice/MoiseevD/lesson_4_3.py b/Practice/MoiseevD/lesson_4_3.py index 4b38be5..eef8361 100644 --- a/Practice/MoiseevD/lesson_4_3.py +++ b/Practice/MoiseevD/lesson_4_3.py @@ -1,7 +1,7 @@ str_num = "" while True: - s = input('Введите число: ') + s = input('Введите число, для выхода введите "stop" : ') if s.lower() == 'stop': break @@ -11,4 +11,4 @@ continue str_num += s - print(str_num) +print(str_num) diff --git a/Practice/MoiseevD/lesson_4_4.py b/Practice/MoiseevD/lesson_4_4.py index 24f620a..814a134 100644 --- a/Practice/MoiseevD/lesson_4_4.py +++ b/Practice/MoiseevD/lesson_4_4.py @@ -4,11 +4,11 @@ s = ('Ты сам-то понял, что написал?', 'Аргументируй', 'И?') while True: - answers = random.choice(s) question = input('Задайте вопрос: ') if question.lower() == 'хватит': print('---Выход из программы---') break else: + answers = random.choice(s) print(answers) diff --git a/Practice/MoiseevD/lesson_4_7.py b/Practice/MoiseevD/lesson_4_7.py index 1f92955..d589a9f 100644 --- a/Practice/MoiseevD/lesson_4_7.py +++ b/Practice/MoiseevD/lesson_4_7.py @@ -1,14 +1,16 @@ def decor_start(start): def decor_finish(*args, **kwargs): + print("=====1======") res = start(*args, **kwargs) + print("=====2======") return res return decor_finish @decor_start def start_finish(start): - print(f'После запуска функции {start}') + print(start) + + +start_finish('=================') -line = "============" -print(f'До запуска функции {line}') -start_finish(line) diff --git a/Practice/MoiseevD/lesson_4_8.py b/Practice/MoiseevD/lesson_4_8.py index 37c5c4e..51e958f 100644 --- a/Practice/MoiseevD/lesson_4_8.py +++ b/Practice/MoiseevD/lesson_4_8.py @@ -1,28 +1,37 @@ import random -game_list = ["камень", "ножницы", "бумага"] -game = random.choice(game_list) +game_list = ("камень", "ножницы", "бумага") while True: + game = random.choice(game_list) s = input('Введите слово "КАМЕНЬ", "НОЖНИЦЫ", или "БУМАГА": ') - if s.lower() == 'камень' and game == game_list[0]: - print(f'---{game}---\n Ничья') - elif s.lower() == 'камень' and game == game_list[1]: - print(f'---{game}---\n Вы выиграли') - elif s.lower() == 'камень' and game == game_list[2]: - print(f'---{game}---\n Вы проиграли') + if s.lower() == 'камень': + if game == game_list[0]: + print(f'---{game}---\n Ничья') + if s.lower() == 'камень': + if game == game_list[1]: + print(f'---{game}---\n Вы выиграли') + if s.lower() == 'камень': + if game == game_list[2]: + print(f'---{game}---\n Вы проиграли') - elif s.lower() == 'ножницы' and game == game_list[0]: - print(f'---{game}---\n Вы проиграли') - elif s.lower() == 'ножницы' and game == game_list[1]: - print(f'---{game}---\n Ничья') - elif s.lower() == 'ножницы' and game == game_list[2]: - print(f'---{game}---\n Вы выиграли') + if s.lower() == 'ножницы': + if game == game_list[0]: + print(f'---{game}---\n Вы проиграли') + if s.lower() == 'ножницы': + if game == game_list[1]: + print(f'---{game}---\n Ничья') + if s.lower() == 'ножницы': + if game == game_list[2]: + print(f'---{game}---\n Вы выиграли') - elif s.lower() == 'бумага' and game == game_list[0]: - print(f'---{game}---\n Вы выиграли') - elif s.lower() == 'бумага' and game == game_list[1]: - print(f'---{game}---\n Вы проиграли') - elif s.lower() == 'бумага' and game == game_list[2]: - print(f'---{game}---\n Ничья') \ No newline at end of file + if s.lower() == 'бумага': + if game == game_list[0]: + print(f'---{game}---\n Вы выиграли') + if s.lower() == 'бумага': + if game == game_list[1]: + print(f'---{game}---\n Вы проиграли') + if s.lower() == 'бумага': + if game == game_list[2]: + print(f'---{game}---\n Ничья') \ No newline at end of file diff --git a/Practice/MoiseevD/lesson_5_1.py b/Practice/MoiseevD/lesson_5_1.py index ff03bde..4073ed1 100644 --- a/Practice/MoiseevD/lesson_5_1.py +++ b/Practice/MoiseevD/lesson_5_1.py @@ -1,20 +1,22 @@ def current_index(arr, idx): idx_min = idx - #i = idx # Вариант с циклом while + i = idx # while i < len(arr): # if arr[i] < arr[idx_min]: # idx_min = i # i += 1 - for i in range(idx, len(arr)): # Вариант с циклом for + for i in range(idx, len(arr)): if arr[i] < arr[idx_min]: idx_min = i + i += 1 return idx_min def min_element(elm): for i in range(len(elm)): cur_idx = current_index(elm, i) - elm[cur_idx], elm[i] = elm[i], elm[cur_idx] + if cur_idx != i: + elm[cur_idx], elm[i] = elm[i], elm[cur_idx] return elm From 37a46b2595f2d001a175447120d2c6a358fd8c27 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 6 Oct 2022 21:34:53 +0300 Subject: [PATCH 12/18] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_4_8.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/Practice/MoiseevD/lesson_4_8.py b/Practice/MoiseevD/lesson_4_8.py index 51e958f..c8be3eb 100644 --- a/Practice/MoiseevD/lesson_4_8.py +++ b/Practice/MoiseevD/lesson_4_8.py @@ -6,32 +6,27 @@ while True: game = random.choice(game_list) s = input('Введите слово "КАМЕНЬ", "НОЖНИЦЫ", или "БУМАГА": ') - if s.lower() == 'камень': + s = s.lower() + if s == 'камень': if game == game_list[0]: print(f'---{game}---\n Ничья') - if s.lower() == 'камень': - if game == game_list[1]: + elif game == game_list[1]: print(f'---{game}---\n Вы выиграли') - if s.lower() == 'камень': - if game == game_list[2]: + else: print(f'---{game}---\n Вы проиграли') - if s.lower() == 'ножницы': + elif s == 'ножницы': if game == game_list[0]: print(f'---{game}---\n Вы проиграли') - if s.lower() == 'ножницы': - if game == game_list[1]: + elif game == game_list[1]: print(f'---{game}---\n Ничья') - if s.lower() == 'ножницы': - if game == game_list[2]: + else: print(f'---{game}---\n Вы выиграли') - if s.lower() == 'бумага': + elif s.lower() == 'бумага': if game == game_list[0]: print(f'---{game}---\n Вы выиграли') - if s.lower() == 'бумага': - if game == game_list[1]: + elif game == game_list[1]: print(f'---{game}---\n Вы проиграли') - if s.lower() == 'бумага': - if game == game_list[2]: + else: print(f'---{game}---\n Ничья') \ No newline at end of file From 4d3f2431dada3597800d5ae9fed41375432f406c Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 7 Oct 2022 18:39:10 +0300 Subject: [PATCH 13/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_6_1.py | 39 ++++++++++++++++++++++++ Practice/MoiseevD/lesson_6_2.py | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 Practice/MoiseevD/lesson_6_1.py create mode 100644 Practice/MoiseevD/lesson_6_2.py diff --git a/Practice/MoiseevD/lesson_6_1.py b/Practice/MoiseevD/lesson_6_1.py new file mode 100644 index 0000000..56cc23b --- /dev/null +++ b/Practice/MoiseevD/lesson_6_1.py @@ -0,0 +1,39 @@ +class Tank: + Model = 'Tank' + def __init__(self, power): + self.power = power + + +class T34(Tank): + tank_model = 'T34' + def shoot(self): + print(self.tank_model, ' - Бах') + + +class Tiger(Tank): + tank_model = 'Tiger' + def shoot(self): + print(self.tank_model, ' - Ба-бах') + + +class Abrams(Tank): + tank_model = 'Abrams' + def shoot(self): + print(self.tank_model, ' - Ба-ба-бах') + + +while True: + t = input('Введите одну из мощностей выстрела: 30 - 80 - 90 ') + if t.lower() == 'stop': + print('Выход из программы') + break + elif t == '30': + tnk1 = T34(30) + tnk1.shoot() + elif t == '80': + tnk2 = Tiger(80) + tnk2.shoot() + elif t == '90': + tnk3 = Abrams(90) + tnk3.shoot() + diff --git a/Practice/MoiseevD/lesson_6_2.py b/Practice/MoiseevD/lesson_6_2.py new file mode 100644 index 0000000..31aeb3e --- /dev/null +++ b/Practice/MoiseevD/lesson_6_2.py @@ -0,0 +1,54 @@ +class Duck: + def __init__(self, name, weight, collor): + self._name = name + self._weight = weight + self._collor = collor + + + def name_weight(self): + print('Имя:', self._name, ' Вес:', self._weight, 'кг') + + + def __repr__(self): + return f'class Duck: name = {self._name} weight = {self._weight} collor = {self._collor}' + + + def __lt__(self, other): + if self._weight < other._weight: + return other._name + else: + return self._name + + + def __ne__(self, other): + if self._weight != other._weight: + return False + else: + return True + + + def __add__(self, other): + return self._weight + other._weight + + + @classmethod + def collor_duck(cls, collor): + print(cls, collor) + + @staticmethod + def crack_duck(): + print('Crack') + + +p = Duck('Гага', 4, 'белый',) +p1 = Duck('КряКря', 7, 'черный',) + +p.crack_duck() +p.collor_duck('черный') +p.name_weight() +print(p.__repr__()) +print(p1.__repr__()) +print('Самая тяжелая утка: ', p < p1) +print('Вес равен или не равен: ', p != p1) +print('Общий вес уток: ', p + p1) + From 306c941123ddb0f59621887ceeb6be826dd26d4e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sun, 9 Oct 2022 16:22:21 +0300 Subject: [PATCH 14/18] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_6_2.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Practice/MoiseevD/lesson_6_2.py b/Practice/MoiseevD/lesson_6_2.py index 31aeb3e..5989166 100644 --- a/Practice/MoiseevD/lesson_6_2.py +++ b/Practice/MoiseevD/lesson_6_2.py @@ -4,33 +4,24 @@ def __init__(self, name, weight, collor): self._weight = weight self._collor = collor - def name_weight(self): print('Имя:', self._name, ' Вес:', self._weight, 'кг') - def __repr__(self): return f'class Duck: name = {self._name} weight = {self._weight} collor = {self._collor}' - def __lt__(self, other): if self._weight < other._weight: return other._name else: return self._name - def __ne__(self, other): - if self._weight != other._weight: - return False - else: - return True - + return self._weight != other._weight def __add__(self, other): return self._weight + other._weight - @classmethod def collor_duck(cls, collor): print(cls, collor) @@ -46,9 +37,9 @@ def crack_duck(): p.crack_duck() p.collor_duck('черный') p.name_weight() -print(p.__repr__()) -print(p1.__repr__()) +print(repr(p)) +print(repr(p1)) print('Самая тяжелая утка: ', p < p1) -print('Вес равен или не равен: ', p != p1) +print('Вес уток не равен: ', p != p1) print('Общий вес уток: ', p + p1) From 0bb52f018300188a4e4324bbd700d1c4d5635be1 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 11 Oct 2022 19:32:57 +0300 Subject: [PATCH 15/18] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_6_1.py | 24 ++++++++---------------- Practice/MoiseevD/lesson_6_2.py | 1 - 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Practice/MoiseevD/lesson_6_1.py b/Practice/MoiseevD/lesson_6_1.py index 56cc23b..57643a5 100644 --- a/Practice/MoiseevD/lesson_6_1.py +++ b/Practice/MoiseevD/lesson_6_1.py @@ -1,26 +1,19 @@ class Tank: - Model = 'Tank' - def __init__(self, power): + def __init__(self, power, model): self.power = power - + self.model = model class T34(Tank): - tank_model = 'T34' def shoot(self): - print(self.tank_model, ' - Бах') - + print(self.model, ' - Бах') class Tiger(Tank): - tank_model = 'Tiger' def shoot(self): - print(self.tank_model, ' - Ба-бах') - + print(self.model, ' - Ба-бах') class Abrams(Tank): - tank_model = 'Abrams' def shoot(self): - print(self.tank_model, ' - Ба-ба-бах') - + print(self.model, ' - Ба-ба-бах') while True: t = input('Введите одну из мощностей выстрела: 30 - 80 - 90 ') @@ -28,12 +21,11 @@ def shoot(self): print('Выход из программы') break elif t == '30': - tnk1 = T34(30) + tnk1 = T34(30, 'T34') tnk1.shoot() elif t == '80': - tnk2 = Tiger(80) + tnk2 = Tiger(80, 'Tiger') tnk2.shoot() elif t == '90': - tnk3 = Abrams(90) + tnk3 = Abrams(90, 'Abrams') tnk3.shoot() - diff --git a/Practice/MoiseevD/lesson_6_2.py b/Practice/MoiseevD/lesson_6_2.py index 5989166..40c1f73 100644 --- a/Practice/MoiseevD/lesson_6_2.py +++ b/Practice/MoiseevD/lesson_6_2.py @@ -42,4 +42,3 @@ def crack_duck(): print('Самая тяжелая утка: ', p < p1) print('Вес уток не равен: ', p != p1) print('Общий вес уток: ', p + p1) - From 162b29322a9bd12cf84f779703ef1789f7da55f8 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 19 Oct 2022 21:18:56 +0300 Subject: [PATCH 16/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_7_1.py | 10 +++++++ Practice/MoiseevD/lesson_7_2.py | 21 +++++++++++++++ Practice/MoiseevD/lesson_7_3.py | 48 +++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 Practice/MoiseevD/lesson_7_1.py create mode 100644 Practice/MoiseevD/lesson_7_2.py create mode 100644 Practice/MoiseevD/lesson_7_3.py diff --git a/Practice/MoiseevD/lesson_7_1.py b/Practice/MoiseevD/lesson_7_1.py new file mode 100644 index 0000000..ebf353b --- /dev/null +++ b/Practice/MoiseevD/lesson_7_1.py @@ -0,0 +1,10 @@ +class Man: + def __init__(self, name): + self._name = name + + def solve_task(self): + print("I'm not ready yet") + + +res = Man('Дмитрий') +res.solve_task() \ No newline at end of file diff --git a/Practice/MoiseevD/lesson_7_2.py b/Practice/MoiseevD/lesson_7_2.py new file mode 100644 index 0000000..1091f1b --- /dev/null +++ b/Practice/MoiseevD/lesson_7_2.py @@ -0,0 +1,21 @@ +import time +import random + + +class Pupil: + def __init__(self, name): + self._name = name + + def solve_task(self): + print("I'm not ready yet") + + +class Tim(Pupil): + def solve_task(self): + n = random.randint(3, 6) + time.sleep(n) + super().solve_task() + + +res = Tim('Дмитрий') +res.solve_task() \ No newline at end of file diff --git a/Practice/MoiseevD/lesson_7_3.py b/Practice/MoiseevD/lesson_7_3.py new file mode 100644 index 0000000..409fcdf --- /dev/null +++ b/Practice/MoiseevD/lesson_7_3.py @@ -0,0 +1,48 @@ +class Bank: + def __init__(self, cash): + self._cash = cash + + +class Bankomat1(Bank): + def input_output(self): + while True: + inp = input('Внести деньги - введите "1". Для снятия - "2" ') + if inp.lower() == '1': + inp = int(input('Положите купюры в лоток: ')) + self._cash += inp + elif inp.lower() == '2': + out = int(input('Введите требуемую сумму: ')) + if self._cash < out: + print('=== Не достаточно денег в банкомате ===') + continue + self._cash -= out + else: + print('----- Неправильный ввод.-----\n ' + 'Для выхода введите: EXIT \n' + 'Для продолжения операции введите любой знак: ') + stop = input('---- ') + if stop.lower() == 'exit': + print('Выход') + break + continue + print(f'Оставшаяся наличность в Bankomat1 : {self._cash}') + + +class Bankomat2(Bank): + def exchange(self): + print(f'Оставшаяся наличность в Bankomat2: {self._cash}') + + +class Bankomat3(Bank): + def transfer(self): + print(f'Оставшаяся наличность в Bankomat3: {self._cash}') + + +#lst = Bank(1000) +lst1 = Bankomat1(500) +lst2 = Bankomat2(1500) +lst3 = Bankomat3(3000) + +lst1.input_output() +lst2.exchange() +lst3.transfer() \ No newline at end of file From 0240b0d5862a28b7836c48839ac09fd4a666fd9e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sun, 23 Oct 2022 19:27:00 +0300 Subject: [PATCH 17/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/read_8_1.txt | 1 + Practice/MoiseevD/read_8_2.txt | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 Practice/MoiseevD/read_8_1.txt create mode 100644 Practice/MoiseevD/read_8_2.txt diff --git a/Practice/MoiseevD/read_8_1.txt b/Practice/MoiseevD/read_8_1.txt new file mode 100644 index 0000000..c0b74e0 --- /dev/null +++ b/Practice/MoiseevD/read_8_1.txt @@ -0,0 +1 @@ + Реализовать итератор, который бы "читал" заданный текст по параграфам. &Символ параграфа задается отдельно. \ No newline at end of file diff --git a/Practice/MoiseevD/read_8_2.txt b/Practice/MoiseevD/read_8_2.txt new file mode 100644 index 0000000..b8adf60 --- /dev/null +++ b/Practice/MoiseevD/read_8_2.txt @@ -0,0 +1,3 @@ +Привет! +Добро пожаловать на Python. +Удачи в обучении! \ No newline at end of file From 5f18ada6020d4e4e163b8a84b5222fd5fe29ae3d Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sun, 23 Oct 2022 22:49:17 +0300 Subject: [PATCH 18/18] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Practice/MoiseevD/lesson_8_3.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Practice/MoiseevD/lesson_8_3.py diff --git a/Practice/MoiseevD/lesson_8_3.py b/Practice/MoiseevD/lesson_8_3.py new file mode 100644 index 0000000..5e2174c --- /dev/null +++ b/Practice/MoiseevD/lesson_8_3.py @@ -0,0 +1,19 @@ +import time + + +class timeManager: + + def __enter__(self): + self.t1 = time.time() + print(f'Запуск таймера в менеджере контекста {self.t1}') + + def __exit__(self, exc_type, exc_val, exc_tb): + self.t2 = time.time() - self.t1 + print('Остановка таймера менеджера контекста') + print(f'Время исполнения кода {self.t2}') + + +lst =range(2, 100000) +with timeManager(): + for i in lst: + print(i)