From 8e439972a73464d9361581cf82e80d665f97433b Mon Sep 17 00:00:00 2001 From: Neuf Date: Sun, 14 Sep 2025 21:13:05 +0500 Subject: [PATCH 01/16] Add test file and say hello --- Module16/helloworld.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 Module16/helloworld.py diff --git a/Module16/helloworld.py b/Module16/helloworld.py new file mode 100644 index 0000000..9ea5ec5 --- /dev/null +++ b/Module16/helloworld.py @@ -0,0 +1 @@ +print('Hi there!') \ No newline at end of file From 216a6a83391d712a8117fba4b64121cee8b6db36 Mon Sep 17 00:00:00 2001 From: Neuf Date: Sun, 14 Sep 2025 23:53:23 +0500 Subject: [PATCH 02/16] =?UTF-8?q?1-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/01_videocards/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Module16/01_videocards/main.py b/Module16/01_videocards/main.py index da21048..572c3b3 100644 --- a/Module16/01_videocards/main.py +++ b/Module16/01_videocards/main.py @@ -1,3 +1,18 @@ # TODO здесь писать код +# GPU_list = [3070, 2060, 3090, 3070, 3090] +GPU_list = [] +new_GPU_list = [] +count_gpu = int(input('Кол-во видеокарт: ')) +for i in range(1, count_gpu + 1): + GPU_list.append(int(input(f'{i}-Видеокарта: '))) + +max_model = max(GPU_list) + +for value in GPU_list: + if value != max_model: + new_GPU_list.append(value) + +print('\nСтарый список видеокарт:', GPU_list) +print('Новый список видеокарт:', new_GPU_list) From fc38f775b463b8bde3bb7289c20d0df91d7dcfd1 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 00:17:22 +0500 Subject: [PATCH 03/16] =?UTF-8?q?2-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/02_movie/main.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Module16/02_movie/main.py b/Module16/02_movie/main.py index f859913..273bc5b 100644 --- a/Module16/02_movie/main.py +++ b/Module16/02_movie/main.py @@ -3,3 +3,20 @@ films = ['Крепкий орешек', 'Назад в будущее', 'Так 'Мементо', 'Отступники', 'Деревня'] # TODO здесь писать код +favorite_films = [] + +add_films = int(input('Сколько фильмов хотите добавить? ')) + + +for _ in range(add_films): + film_name = input('Введите название фильма: ') + if film_name in films: + favorite_films.append(film_name) + else: + print(f'Ошибка: фильма {film_name} у нас нет :(') + +print('Ваш список любимых фильмов:', end=' ') +for i_film in range(len(favorite_films)-1): + print(favorite_films[i_film], end=', ') +else: + print(favorite_films[len(favorite_films)-1]) \ No newline at end of file From be275fa1017d18a2d194e3a6022ea3079a3dea58 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 01:57:35 +0500 Subject: [PATCH 04/16] =?UTF-8?q?3-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/03_running_nums/main.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Module16/03_running_nums/main.py b/Module16/03_running_nums/main.py index 9b7f69c..da5e83e 100644 --- a/Module16/03_running_nums/main.py +++ b/Module16/03_running_nums/main.py @@ -1 +1,32 @@ # TODO здесь писать код +def show_list(collection, secret): + if secret == 'first': + print('Изначальный список:', end=' ') + elif secret == 'after': + print('Сдвинутый список:', end=' ') + print('[', end='') + for i_collection in range(len(collection) - 1): + print(collection[i_collection], end=', ') + print(collection[len(collection) - 1], end=']') + print() + +def rebuild_list(collection, index): + new_collection = [] + step = len(collection) + while step > 0: + if len(collection) <= index or index < 0: + index %= len(collection) + # elif abs(step + index) == 0: + # index = 0 + # elif index < 0: + # index = abs(len(collection)- 1 - index) % len(collection) + new_collection.append(collection[index]) + index += 1 + step -= 1 + return new_collection + +list_for_view = [1, 2, 3, 4, 5] + +shift = int(input('Сдвиг: ')) +show_list(list_for_view, 'first') +show_list(rebuild_list(list_for_view, shift), 'after') \ No newline at end of file From 42c9d950e7ab618200cac0bdfd415b7b686e6ef2 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 02:29:40 +0500 Subject: [PATCH 05/16] =?UTF-8?q?4-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/04_word_analysis_2/main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Module16/04_word_analysis_2/main.py b/Module16/04_word_analysis_2/main.py index 9b7f69c..ed1423c 100644 --- a/Module16/04_word_analysis_2/main.py +++ b/Module16/04_word_analysis_2/main.py @@ -1 +1,23 @@ # TODO здесь писать код +def check_word(word): + length = len(word) + diff = length // 2 + for i in range(diff): + if word[i] != word[length - i - 1]: + return False # Плюс к тому же, как только есть несоответствие - прерываем цикл + else: + return True + + + +text = input('Введите слово: ') + +if text == text[::-1] and check_word(text): + print('Слово является палиндромом') +else: + print('Слово не является палиндромом') + +# Но по данному методу ([::-1]), мы запускаем цикл, который работает len(text) раз +# А если проверять сразу по два символа (check_word()), то это в два раза ускоряет выполнение нашей программы? + + From 3a391ca377b58745a2a7ef0c0e3de389fc61d935 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 02:30:54 +0500 Subject: [PATCH 06/16] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/helloworld.py | 1 - main.py | 1 - 2 files changed, 2 deletions(-) delete mode 100644 Module16/helloworld.py delete mode 100644 main.py diff --git a/Module16/helloworld.py b/Module16/helloworld.py deleted file mode 100644 index 9ea5ec5..0000000 --- a/Module16/helloworld.py +++ /dev/null @@ -1 +0,0 @@ -print('Hi there!') \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index adb3730..0000000 --- a/main.py +++ /dev/null @@ -1 +0,0 @@ -print("My name is Alisher") \ No newline at end of file From 9615b9e47c212ae22d9d77a29e8b0f5662f6254e Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 02:57:13 +0500 Subject: [PATCH 07/16] =?UTF-8?q?5-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/05_sort/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Module16/05_sort/main.py b/Module16/05_sort/main.py index 9b7f69c..a1c1fd7 100644 --- a/Module16/05_sort/main.py +++ b/Module16/05_sort/main.py @@ -1 +1,14 @@ # TODO здесь писать код +sort_this_number = [-67, 4, -3, 0, -5] + +print('Изначальный список:', sort_this_number) + +for i_number in range(len(sort_this_number)-1): + for i_next_number in range(i_number + 1, len(sort_this_number)): + _min = sort_this_number[i_number] # можно обойтись без этих переменных, но код станет не очень читаемым... + _max = sort_this_number[i_next_number] + if _min > _max: + sort_this_number[i_number] = _max + sort_this_number[i_next_number] = _min + +print('Отсортированный список:',sort_this_number) \ No newline at end of file From 98fbfea8d508bc00a2d86182d3beea4a73eb289a Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 03:14:28 +0500 Subject: [PATCH 08/16] Save for work in another place --- Module16/06_unique_combination/main.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Module16/06_unique_combination/main.py b/Module16/06_unique_combination/main.py index 374a42e..f0e81d0 100644 --- a/Module16/06_unique_combination/main.py +++ b/Module16/06_unique_combination/main.py @@ -2,7 +2,21 @@ # Пример использования: -list1 = [1, 3, 5, 7, 9] +list1 = [1, 3, 5, 7, 9, 5] list2 = [2, 4, 5, 6, 8, 10] -merged = merge_sorted_lists(list1, list2) -print(merged) \ No newline at end of file + +list1.extend(list2) +list3 = [] +for i_number in range(len(list1)): + for i_next_number in range(i_number + 1, len(list1)+1): + _min = list1[i_number] # можно обойтись без этих переменных, но код станет не очень читаемым... + _max = list1[i_next_number] + if _min > _max: + list1[i_number] = _max + elif _min < _min: + list1[i_number] = _min + else: + list1.remove(_min) + +# merged = merge_sorted_lists(list1, list2) +# print(merged) \ No newline at end of file From 462690ae097426da2885058fe98c6a0cabe83f71 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 15:19:31 +0500 Subject: [PATCH 09/16] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/06_unique_combination/main.py | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Module16/06_unique_combination/main.py b/Module16/06_unique_combination/main.py index f0e81d0..c93923e 100644 --- a/Module16/06_unique_combination/main.py +++ b/Module16/06_unique_combination/main.py @@ -1,22 +1,22 @@ # TODO здесь писать код +def merge_sorted_lists(collection1, collection2): + result_collection = [] + for value2 in collection2: + for value1 in collection1: + if value2 == value1: + break + else: + result_collection.append(value2) + print(result_collection) + result_collection.extend(collection1) + print(result_collection) + result_collection.sort() + print(result_collection) + return result_collection # Пример использования: list1 = [1, 3, 5, 7, 9, 5] list2 = [2, 4, 5, 6, 8, 10] - -list1.extend(list2) -list3 = [] -for i_number in range(len(list1)): - for i_next_number in range(i_number + 1, len(list1)+1): - _min = list1[i_number] # можно обойтись без этих переменных, но код станет не очень читаемым... - _max = list1[i_next_number] - if _min > _max: - list1[i_number] = _max - elif _min < _min: - list1[i_number] = _min - else: - list1.remove(_min) - -# merged = merge_sorted_lists(list1, list2) -# print(merged) \ No newline at end of file +merged = merge_sorted_lists(list1, list2) +print(merged) \ No newline at end of file From bd59a5aea2196d53457fd1fdac46e76536d0a362 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 17:30:46 +0500 Subject: [PATCH 10/16] =?UTF-8?q?6-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/06_unique_combination/main.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Module16/06_unique_combination/main.py b/Module16/06_unique_combination/main.py index c93923e..b809168 100644 --- a/Module16/06_unique_combination/main.py +++ b/Module16/06_unique_combination/main.py @@ -7,16 +7,12 @@ def merge_sorted_lists(collection1, collection2): break else: result_collection.append(value2) - print(result_collection) result_collection.extend(collection1) - print(result_collection) result_collection.sort() - print(result_collection) - return result_collection # Пример использования: -list1 = [1, 3, 5, 7, 9, 5] +list1 = [1, 3, 5, 7, 9] list2 = [2, 4, 5, 6, 8, 10] merged = merge_sorted_lists(list1, list2) print(merged) \ No newline at end of file From ef5b656a226672dbd89bf97a1b67d44ac28e2f7e Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 17:39:45 +0500 Subject: [PATCH 11/16] =?UTF-8?q?7-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/07_details/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Module16/07_details/main.py b/Module16/07_details/main.py index 3cad702..d1400f6 100644 --- a/Module16/07_details/main.py +++ b/Module16/07_details/main.py @@ -11,3 +11,15 @@ shop = [ ] # TODO здесь писать код + +search_item = input('Название детали: ') +amount = 0 +summ = 0 + +for item in shop: + if item[0] == search_item: + summ += item[1] + amount += 1 + +print('Кол-во деталей —', amount) +print('Общая стоимость —', summ) \ No newline at end of file From 1bb29cfb72556de4b011c802f983dbee36d26836 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 20:26:50 +0500 Subject: [PATCH 12/16] =?UTF-8?q?8-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/08_songs/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Module16/08_songs/main.py b/Module16/08_songs/main.py index 0d14d68..c218c13 100644 --- a/Module16/08_songs/main.py +++ b/Module16/08_songs/main.py @@ -11,3 +11,15 @@ violator_songs = [ ] # TODO здесь писать код +summ_time = 0.00 + +amount = int(input('Сколько песен выбрать? ')) + +for i in range(1, amount + 1): + song = input(f'Название {i}-й песни: ') + for song_option in violator_songs: + if song_option[0] == song: + summ_time += song_option[1] + break + +print(f'Общее время звучания песен: {round(summ_time, 2)} минуты') \ No newline at end of file From 02eb5cf4fbf1823c0f12e5c805fa2a26dcefc535 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 21:09:48 +0500 Subject: [PATCH 13/16] =?UTF-8?q?9-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/09_roller_skates/main.py | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Module16/09_roller_skates/main.py b/Module16/09_roller_skates/main.py index 9b7f69c..484d1ed 100644 --- a/Module16/09_roller_skates/main.py +++ b/Module16/09_roller_skates/main.py @@ -1 +1,35 @@ # TODO здесь писать код +def fill_size_list(number, whose: str): + collection = [] + if whose == 'skates': + text_first = 'Размер ' + text_last = '-й пары: ' + else: + text_first = 'Размер ноги ' + text_last = '-го человека: ' + for i in range(1, number + 1): + collection.append(int(input(f'{text_first}{i}{text_last}'))) + return collection + +number_sizes_skates = int(input("Кол-во коньков: ")) +skates_size_list = fill_size_list(number_sizes_skates, 'skates') +print() +number_sizes_legs = int(input('Кол-во людей: ')) +legs_size_list = fill_size_list(number_sizes_legs, 'legs') +print() + +# Я так и не понял, для чего искать наименьший подходящий размер... :( +# skates_size_list.sort() +# legs_size_list.sort() + +count_busy = 0 +for leg in legs_size_list: + for i_skate, skate in enumerate(skates_size_list): + if leg == skate: + skates_size_list[i_skate] = 0 + count_busy += 1 + break + +print('Наибольшее кол-во людей, которые могут взять ролики:', count_busy) + + From 54ced685d75a0151c47cd9fd561846d668581773 Mon Sep 17 00:00:00 2001 From: Neuf Date: Mon, 15 Sep 2025 22:41:05 +0500 Subject: [PATCH 14/16] =?UTF-8?q?10-=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/10_rhyme_cnt/main.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Module16/10_rhyme_cnt/main.py b/Module16/10_rhyme_cnt/main.py index 9b7f69c..7e7adac 100644 --- a/Module16/10_rhyme_cnt/main.py +++ b/Module16/10_rhyme_cnt/main.py @@ -1 +1,25 @@ # TODO здесь писать код +count_people = int(input('Кол-во человек: ')) +peoples = list(range(1, count_people + 1)) + +count_number = int(input('Какое число в считалке? ')) +print(f'Значит, выбывает каждый {count_number}-й человек\n') + +# Скорее всего не оптимальное решение. +# Решал чисто "интуитивно", с помощью дебага и "экспериментов" с вычислениями +leave = 0 +while len(peoples) > 1: + print('Текущий круг людей:', peoples) + print('Начало счёта с номера', peoples[leave]) + leave = (leave + count_number) % len(peoples) + if leave == 0: + leave = len(peoples) - 1 + else: + leave -= 1 + print('Выбывает человек под номером', peoples[leave]) + print() + peoples.remove(peoples[leave]) + if leave >= len(peoples): + leave %= len(peoples) + +print('Остался человек под номером', peoples[0]) \ No newline at end of file From f3c81fda32e971a98b366420f5093e5b3a32516f Mon Sep 17 00:00:00 2001 From: Neuf Date: Tue, 16 Sep 2025 00:50:16 +0500 Subject: [PATCH 15/16] =?UTF-8?q?=D0=94=D0=BE=D0=BC=D0=B0=D1=88=D0=BD?= =?UTF-8?q?=D1=8F=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D1=86?= =?UTF-8?q?=D0=B5=D0=BB=D0=B8=D0=BA=D0=BE=D0=BC=20=D0=B2=D1=8B=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=B5=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/11_simmetrical_seq/main.py | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Module16/11_simmetrical_seq/main.py b/Module16/11_simmetrical_seq/main.py index 9b7f69c..2548175 100644 --- a/Module16/11_simmetrical_seq/main.py +++ b/Module16/11_simmetrical_seq/main.py @@ -1 +1,49 @@ # TODO здесь писать код +# По примерам, я так понял, что, пользователь не вводит цифру 0 +# Решил немного смухлевать +def check_numbers(collection): + temp = [] # Из-за того что родительский список тоже менялся, + temp.extend(collection) # пришлось городить такой способ + length = len(temp) + diff = length // 2 + remain = length % 2 + for i in range(diff): + index_left = (diff - i) - 1 + index_right = (diff + i) + remain + if temp[index_right] == 0: + continue + if temp[index_left] != temp[index_right]: + return False + else: + return True + +def rebuild(collection, number): + for i_number in range(number, 0, -1): + collection.append(collection[i_number-1]) + +def count_changes(collection): + number = 0 + temp_collection = [] # Из-за того что родительский список тоже менялся, + temp_collection.extend(collection) # пришлось городить такой способ + while not check_numbers(temp_collection): + temp_collection.append(0) + number += 1 + return number + +numbers_list = [] +numbers = int(input('Кол-во чисел: ')) +for i in range(numbers): + numbers_list.append(int(input('Число: '))) +print() +print('Последовательность:',numbers_list) + +step_count = count_changes(numbers_list) +rebuild(numbers_list, step_count) # Даже без return родительский список все равно меняется :-\ +# print(numbers) +if step_count != 0: + print('Нужно приписать чисел:', step_count) + print('Сами числа: [', end='') + for i_num in range(len(numbers_list) - step_count, len(numbers_list) -1): + print(numbers_list[i_num],end=', ') + else: + print(f'{numbers_list[len(numbers_list) -1]}]') From b79eabe0918e9a685c8294b4b6946cab5aa8966d Mon Sep 17 00:00:00 2001 From: Neuf Date: Fri, 19 Sep 2025 00:45:51 +0500 Subject: [PATCH 16/16] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=87=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8E=20=D0=BA=D1=83=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module16/01_videocards/main.py | 24 +++++++++++++----------- Module16/02_movie/main.py | 19 +++++++++++-------- Module16/05_sort/main.py | 20 +++++++++++--------- Module16/07_details/main.py | 20 ++++++++++---------- 4 files changed, 45 insertions(+), 38 deletions(-) diff --git a/Module16/01_videocards/main.py b/Module16/01_videocards/main.py index 572c3b3..8e6fc6a 100644 --- a/Module16/01_videocards/main.py +++ b/Module16/01_videocards/main.py @@ -1,18 +1,20 @@ # TODO здесь писать код # GPU_list = [3070, 2060, 3090, 3070, 3090] -GPU_list = [] -new_GPU_list = [] +def input_cards(): + gpu_list = [] + count_gpu = int(input('Кол-во видеокарт: ')) + for i in range(1, count_gpu + 1): + gpu_list.append(int(input(f'{i}-Видеокарта: '))) -count_gpu = int(input('Кол-во видеокарт: ')) +def by_cards(): + new_gpu_list = [] + max_model = max(gpu_list) + for value in gpu_list: + if value != max_model: + new_gpu_list.append(value) -for i in range(1, count_gpu + 1): - GPU_list.append(int(input(f'{i}-Видеокарта: '))) - -max_model = max(GPU_list) - -for value in GPU_list: - if value != max_model: - new_GPU_list.append(value) +input_cards() +by_cards() print('\nСтарый список видеокарт:', GPU_list) print('Новый список видеокарт:', new_GPU_list) diff --git a/Module16/02_movie/main.py b/Module16/02_movie/main.py index 273bc5b..a676478 100644 --- a/Module16/02_movie/main.py +++ b/Module16/02_movie/main.py @@ -3,17 +3,20 @@ films = ['Крепкий орешек', 'Назад в будущее', 'Так 'Мементо', 'Отступники', 'Деревня'] # TODO здесь писать код -favorite_films = [] +def add_films_to_list(): + added_films = [] -add_films = int(input('Сколько фильмов хотите добавить? ')) + add_films = int(input('Сколько фильмов хотите добавить? ')) + for _ in range(add_films): + film_name = input('Введите название фильма: ') + if film_name in films: + added_films.append(film_name) + else: + print(f'Ошибка: фильма {film_name} у нас нет :(') + return added_films -for _ in range(add_films): - film_name = input('Введите название фильма: ') - if film_name in films: - favorite_films.append(film_name) - else: - print(f'Ошибка: фильма {film_name} у нас нет :(') +favorite_films = add_films_to_list() print('Ваш список любимых фильмов:', end=' ') for i_film in range(len(favorite_films)-1): diff --git a/Module16/05_sort/main.py b/Module16/05_sort/main.py index a1c1fd7..4e858b3 100644 --- a/Module16/05_sort/main.py +++ b/Module16/05_sort/main.py @@ -1,14 +1,16 @@ # TODO здесь писать код +def sort_number(): + for i_number in range(len(sort_this_number) - 1): + for i_next_number in range(i_number + 1, len(sort_this_number)): + _min = sort_this_number[i_number] # можно обойтись без этих переменных, но код станет не очень читаемым... + _max = sort_this_number[i_next_number] + if _min > _max: + sort_this_number[i_number] = _max + sort_this_number[i_next_number] = _min + + sort_this_number = [-67, 4, -3, 0, -5] print('Изначальный список:', sort_this_number) - -for i_number in range(len(sort_this_number)-1): - for i_next_number in range(i_number + 1, len(sort_this_number)): - _min = sort_this_number[i_number] # можно обойтись без этих переменных, но код станет не очень читаемым... - _max = sort_this_number[i_next_number] - if _min > _max: - sort_this_number[i_number] = _max - sort_this_number[i_next_number] = _min - +sort_number() print('Отсортированный список:',sort_this_number) \ No newline at end of file diff --git a/Module16/07_details/main.py b/Module16/07_details/main.py index d1400f6..a619410 100644 --- a/Module16/07_details/main.py +++ b/Module16/07_details/main.py @@ -11,15 +11,15 @@ shop = [ ] # TODO здесь писать код +def search(detail_name): + amount = 0 + summ = 0 + for item in shop: + if item[0] == detail_name: + summ += item[1] + amount += 1 + print('Кол-во деталей —', amount) + print('Общая стоимость —', summ) search_item = input('Название детали: ') -amount = 0 -summ = 0 - -for item in shop: - if item[0] == search_item: - summ += item[1] - amount += 1 - -print('Кол-во деталей —', amount) -print('Общая стоимость —', summ) \ No newline at end of file +search(search_item) \ No newline at end of file