From 68be6601c042cdd05a3ca97994847a837e7d7c3f Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Fri, 27 Mar 2026 22:53:27 +0300 Subject: [PATCH 01/15] Update a_user_instance.py --- level_1/a_user_instance.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/level_1/a_user_instance.py b/level_1/a_user_instance.py index e5d0368..71a7ac9 100644 --- a/level_1/a_user_instance.py +++ b/level_1/a_user_instance.py @@ -11,8 +11,8 @@ def __init__(self, name: str, username: str, age: int, phone: str): self.username = username self.age = age self.phone = phone - - + def __str__(self): + return f'Информация о пользователе: {self.name}, {self.username}, {self.age}, {self.phone}' if __name__ == '__main__': - pass # код писать тут - + user = User("Artem", "maharadze", 19, "89162918051") + print(user) From b8a651b1342f72fef449bcc7eff5b4830c37253f Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:12:53 +0300 Subject: [PATCH 02/15] Update b_student_full_name_method.py --- level_1/b_student_full_name_method.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/level_1/b_student_full_name_method.py b/level_1/b_student_full_name_method.py index 14ec439..2a59c38 100644 --- a/level_1/b_student_full_name_method.py +++ b/level_1/b_student_full_name_method.py @@ -5,7 +5,6 @@ 3. Положите результат вызова метода get_full_name в переменную и распечатайте ее. """ - class Student: def __init__(self, name: str, surname: str, faculty: str, course: int): self.name = name @@ -18,5 +17,6 @@ def get_full_name(self): if __name__ == '__main__': - pass # код писать тут + student = Student("Artem", "Nikiforov", "DevOps", 1) + print(student.get_full_name()) From 10370c84ab560007120692e111ea8cb97a4319d5 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:20:53 +0300 Subject: [PATCH 03/15] Update c_product_class.py --- level_1/c_product_class.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/level_1/c_product_class.py b/level_1/c_product_class.py index 3952b66..8292d09 100644 --- a/level_1/c_product_class.py +++ b/level_1/c_product_class.py @@ -9,8 +9,15 @@ class Product: - pass # код писать тут + def __init__(self, name: str, description: str, price: int | str, weight: int): + self.name = name + self.description = description + self.price = price + self.weight = weight + def get_info_product(self): + return f'Информация о продукте: {self.name}, {self.description}, {self.price} р., {self.weight} гр.' if __name__ == '__main__': - pass # код писать тут + product = Product("Bananas", "They are yellow, from tropical countries, very tastye", 30, 100) + print(product.get_info_product()) From 64d836e64b8d40d2d050bb7a161cd42b5ebc0f78 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:26:56 +0300 Subject: [PATCH 04/15] Update d_bank_account_increase_balance.py --- level_1/d_bank_account_increase_balance.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/level_1/d_bank_account_increase_balance.py b/level_1/d_bank_account_increase_balance.py index cc7a16c..cb769b9 100644 --- a/level_1/d_bank_account_increase_balance.py +++ b/level_1/d_bank_account_increase_balance.py @@ -8,15 +8,17 @@ 3. Увеличьте баланс счета у экземпляра класса с помощью метода increase_balance и снова распечатайте текущий баланс. """ - class BankAccount: def __init__(self, owner_full_name: str, balance: float): self.owner_full_name = owner_full_name self.balance = balance - + def balance_bank(self): + return self.balance def increase_balance(self, income: float): - pass # код писать тут - + self.income = income + return self.balance + self.income if __name__ == '__main__': - pass # код писать тут + bank = BankAccount("John", 10000.54) + print(bank.balance_bank()) + print(bank.increase_balance(5252.24)) From 7fa8015be5f246d5d3713c1446807d3c7f7bbc57 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:35:13 +0300 Subject: [PATCH 05/15] Update e_bank_account_decrease_balance.py --- level_1/e_bank_account_decrease_balance.py | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/level_1/e_bank_account_decrease_balance.py b/level_1/e_bank_account_decrease_balance.py index dfd4586..6558cd5 100644 --- a/level_1/e_bank_account_decrease_balance.py +++ b/level_1/e_bank_account_decrease_balance.py @@ -10,8 +10,28 @@ class BankAccount: - pass # код писать тут + def __init__(self, owner_full_name: str, balance: float): + self.owner_full_name = owner_full_name + self.balance = balance + + def balance_bank(self): + return self.balance + + def increase_balance(self, income: float): + self.income = income + return self.balance + self.income + + def reduce_balance(self, reduce: float): + self.reduce = reduce + current_balance = self.balance - self.reduce + if current_balance < 0: + raise ValueError('Отрицательный баланс!') + return current_balance if __name__ == '__main__': - pass # код писать тут + bank = BankAccount("John", 10000.54) + print(bank.balance_bank()) + print(bank.increase_balance(5252.24)) + print(bank.reduce_balance(3254.56)) + print(bank.reduce_balance(15524.55)) From 02378861e7a1f2c7b0baf834bd8c9741dce19450 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:41:04 +0300 Subject: [PATCH 06/15] Update a_user_from_functions_to_class.py --- level_2/a_user_from_functions_to_class.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/level_2/a_user_from_functions_to_class.py b/level_2/a_user_from_functions_to_class.py index 18a64ce..f3f1b93 100644 --- a/level_2/a_user_from_functions_to_class.py +++ b/level_2/a_user_from_functions_to_class.py @@ -4,15 +4,16 @@ Задания: 1. Создайте класс User и перенесите всю логику работы с пользователем туда. """ - - -def make_username_capitalized(username: str): - return username.capitalize() - - -def generate_short_user_description(username: str, user_id: int, name: str): - return f'User with id {user_id} has {username} username and {name} name' - - class User: - pass # код писать тут + def __init__(self, username: str, user_id: int, name: str): + self.username = username + self.user_id = user_id + self.name = name + def make_username_capitalized(self): + return self.username.capitalize() + + def generate_short_user_description(self): + return f'User with id {self.user_id} has {self.username} username and {self.name} name' +user = User("Maharadze", "@dsgdsag", "Artem") +print(user.make_username_capitalized()) +print(user.generate_short_user_description()) From b224091fbffea9e0f3f171e382723587b4e7dd8c Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:44:42 +0300 Subject: [PATCH 07/15] Update b_user_should_be_banned.py --- level_2/b_user_should_be_banned.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/level_2/b_user_should_be_banned.py b/level_2/b_user_should_be_banned.py index 3ec9359..7d8412c 100644 --- a/level_2/b_user_should_be_banned.py +++ b/level_2/b_user_should_be_banned.py @@ -11,4 +11,13 @@ class User: - pass # код писать тут + def __init__(self, name, surname, age): + self.name = name + self.surname = surname + self.age = age + def should_be_banned(self): + if self.surname in SURNAMES_TO_BAN: + return f"Пользователь {self.surname} {self.name} забанен" + +user = User("Artem", "Vaughn", 19) +print(user.should_be_banned()) From 2f93ec0b0d3cb9481d88fe6f5ae3007c8f3b1679 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:56:57 +0300 Subject: [PATCH 08/15] Update a_credit_bank_account.py --- level_3/a_credit_bank_account.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/level_3/a_credit_bank_account.py b/level_3/a_credit_bank_account.py index b73657a..cfb9f8a 100644 --- a/level_3/a_credit_bank_account.py +++ b/level_3/a_credit_bank_account.py @@ -9,9 +9,7 @@ """ # код писать тут - - -class CreditAccount: +class BankAccount: def __init__(self, owner_full_name: str, balance: float): self.owner_full_name = owner_full_name self.balance = balance @@ -22,10 +20,21 @@ def increase_balance(self, amount: float): def decrease_balance(self, amount: float): self.balance -= amount +class CreditAccount(BankAccount): + def __init__(self, owner_full_name: str, balance: float): + super().__init__(owner_full_name, balance) + def increase_balance(self, amount: float): + super().increase_balance(amount) + return self.balance + def decrease_balance(self, amount: float): + super().decrease_balance(amount) + return self.balance def is_eligible_for_credit(self): return self.balance > 1000 if __name__ == '__main__': - pass # код писать тут - + user = CreditAccount("Artem", 10525.25) + print(user.increase_balance(1000)) + print(user.decrease_balance(5000)) + print(user.is_eligible_for_credit()) From 634f0f77f7c1a622add406ab2a75a47d229664c3 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Sat, 28 Mar 2026 16:44:57 +0300 Subject: [PATCH 09/15] Update b_user_manage.py --- level_3/b_user_manage.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/level_3/b_user_manage.py b/level_3/b_user_manage.py index 6417c77..fc2c2e4 100644 --- a/level_3/b_user_manage.py +++ b/level_3/b_user_manage.py @@ -22,9 +22,43 @@ def get_users(self): return self.usernames -# код писать тут +class AdminManager(UserManager): + def __init__(self): + super().__init__() + def get_users(self): + return super().get_users() + def ban_username(self, username): + if username in self.usernames: + self.usernames.remove(username) + else: + print('Такого пользователя не существует') + +class SuperAdminManager(AdminManager): + def __init__(self): + super().__init__() + def ban_all_users(self): + return self.usernames.clear() + def get_users(self): + return super().get_users() if __name__ == '__main__': - pass # код писать тут + user = UserManager() + user.add_user("anna") + user.add_user("artem") + user.add_user("ivan") + print(user.get_users()) + + admin = AdminManager() + admin.add_user('anna') + admin.add_user('gleb') + admin.add_user('ivan') + admin.ban_username('anna') + print(admin.get_users()) + manager = SuperAdminManager() + manager.add_user('anna') + manager.add_user('ivan') + manager.add_user('artem') + manager.ban_all_users() + print(manager.get_users()) From 43f13533f2261295d2ede3cc6dafcd77afe1bc44 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:15:12 +0300 Subject: [PATCH 10/15] Update c_text_processor.py --- level_3/c_text_processor.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/level_3/c_text_processor.py b/level_3/c_text_processor.py index d9aed49..96233bf 100644 --- a/level_3/c_text_processor.py +++ b/level_3/c_text_processor.py @@ -20,8 +20,21 @@ def summarize(self): return f'Total text length: {len(self.text)}' -# код писать тут - +class AdvancedTextProcessor(TextProcessor): + def __init__(self, text): + super().__init__(text) + def to_upper(self): + return super().to_upper() + def summarize(self): + words = self.text.split() + count = len(words) + return f'Total text length: {len(self.text)}, total number of words in the text: {count}' if __name__ == '__main__': - pass # код писать тут + texts = TextProcessor('Total text length: 67, total number of words in the text: 10') + print(texts.to_upper()) + print(texts.summarize()) + + advance = AdvancedTextProcessor('Total text length: 67, total number of words in the text: 10') + print(advance.to_upper()) + print(advance.summarize()) From 73063bbc5d01b4e9ca863cfb2a9bcd57f335df47 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:30:40 +0300 Subject: [PATCH 11/15] Update d_alcohol_product.py --- level_3/d_alcohol_product.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/level_3/d_alcohol_product.py b/level_3/d_alcohol_product.py index 49065b1..045be02 100644 --- a/level_3/d_alcohol_product.py +++ b/level_3/d_alcohol_product.py @@ -26,8 +26,20 @@ def is_available(self): class AlcoholProduct(Product): - pass # код писать тут + def __init__(self, title, price, stock_quantity): + super().__init__(title, price, stock_quantity) + def is_available(self): + super().is_available() + if 5 < datetime.now().hour < 23: + return False + else: + return f'Пейте на здоровье' if __name__ == '__main__': - pass # код писать тут + product = Product('teqila', 1000, 15) + print(product.get_discounted_price(0.75)) + print(product.is_available()) + + alco = AlcoholProduct('teqila', 1000, 15) + print(alco.is_available()) From db94c66fa133c18eca29a621b9d4947da4f520bb Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:06:18 +0300 Subject: [PATCH 12/15] Update d_alcohol_product.py --- level_3/d_alcohol_product.py | 74 +++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/level_3/d_alcohol_product.py b/level_3/d_alcohol_product.py index 045be02..1856479 100644 --- a/level_3/d_alcohol_product.py +++ b/level_3/d_alcohol_product.py @@ -1,45 +1,57 @@ """ -У нас есть класс Product, который содержит в себе информацию о продукте. -Еще у нас есть класс AlcoholProduct, но метод is_available для него не подходит, так как -алкоголь нельзя продавать с 5 утра до 11 вечера +У нас есть класс FileHandler, который может считывать файлы, но не всегда в удобном для нас виде. +Поэтому мы создали два его наследника: CSVHandler и JSONHandler Задания: - 1. Переопределите метод is_available в классе AlcoholProduct с использованием super() - 2. is_available у AlcoholProduct должен возвращать False если сейчас часы между 5 утра и 11 вечера. - Для определения текущего часа можно использовать datetime.now().hour - 3. Создайте экземпляр класса AlcoholProduct и проверьте, можно ли сейчас продавать алкоголь. + 1. Переопределите метод read у CSVHandler и JSONHandler + 2. Метод read у JSONHandler должен возвращать словарь. Для этого используйте модуль встроенный модуль json + 3. Метод read у CSVHandler должен возвращать список словарей. Для этого используйте модуль встроенный модуль csv + 4. Создайте экземпляры каждого из трех классов. + С помощью экземпляра FileHandler прочитайте и распечатайте содержимое файла text.txt + С помощью экземпляра JSONHandler прочитайте и распечатайте содержимое файла recipes.json + С помощью экземпляра CSVHandler прочитайте и распечатайте содержимое файла user_info.csv + """ -from datetime import datetime +import csv +import json + + +class FileHandler: + def __init__(self, filename): + self.filename = filename + def read(self): + with open(self.filename, 'r', encoding='utf-8') as file: + return file.read() -class Product: - def __init__(self, title, price, stock_quantity): - self.title = title - self.price = price - self.stock_quantity = stock_quantity - def get_discounted_price(self, discount_percentage): - return self.price * (1 - discount_percentage / 100) +class JSONHandler(FileHandler): + def __init__(self, filename): + super().__init__(filename) + def read(self): + with open(self.filename, 'r') as file: + return json.load(file) - def is_available(self): - return self.stock_quantity > 0 -class AlcoholProduct(Product): - def __init__(self, title, price, stock_quantity): - super().__init__(title, price, stock_quantity) - def is_available(self): - super().is_available() - if 5 < datetime.now().hour < 23: - return False - else: - return f'Пейте на здоровье' + +class CSVHandler(FileHandler): + def __init__(self, filename): + super().__init__(filename) + def read(self): + with open(self.filename, 'r', encoding='utf-8') as file: + csv_reader = csv.DictReader(file) + data = [row for row in csv_reader] + return data + if __name__ == '__main__': - product = Product('teqila', 1000, 15) - print(product.get_discounted_price(0.75)) - print(product.is_available()) + hand = FileHandler('text.txt') + print(hand.read()) + + jsn = JSONHandler('recipes.json') + print(jsn.read()) - alco = AlcoholProduct('teqila', 1000, 15) - print(alco.is_available()) + cs = CSVHandler('user_info.csv') + print(cs.read()) From b164fab548caabcc5026bd723145948d064f5574 Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:06:56 +0300 Subject: [PATCH 13/15] Update a_file_handler.py --- level_4/a_file_handler.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/level_4/a_file_handler.py b/level_4/a_file_handler.py index c05ce7d..1856479 100644 --- a/level_4/a_file_handler.py +++ b/level_4/a_file_handler.py @@ -21,17 +21,37 @@ def __init__(self, filename): self.filename = filename def read(self): - with open(self.filename, 'r') as file: + with open(self.filename, 'r', encoding='utf-8') as file: return file.read() class JSONHandler(FileHandler): - pass # код писать тут + def __init__(self, filename): + super().__init__(filename) + def read(self): + with open(self.filename, 'r') as file: + return json.load(file) + + class CSVHandler(FileHandler): - pass # код писать тут + def __init__(self, filename): + super().__init__(filename) + def read(self): + with open(self.filename, 'r', encoding='utf-8') as file: + csv_reader = csv.DictReader(file) + data = [row for row in csv_reader] + return data + if __name__ == '__main__': - pass # код писать тут + hand = FileHandler('text.txt') + print(hand.read()) + + jsn = JSONHandler('recipes.json') + print(jsn.read()) + + cs = CSVHandler('user_info.csv') + print(cs.read()) From fb419f7ed3863033977215a32d082919c525c61b Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:10:41 +0300 Subject: [PATCH 14/15] Update d_alcohol_product.py --- level_3/d_alcohol_product.py | 77 ++++++++++++++---------------------- 1 file changed, 30 insertions(+), 47 deletions(-) diff --git a/level_3/d_alcohol_product.py b/level_3/d_alcohol_product.py index 1856479..14871ea 100644 --- a/level_3/d_alcohol_product.py +++ b/level_3/d_alcohol_product.py @@ -1,57 +1,40 @@ -""" -У нас есть класс FileHandler, который может считывать файлы, но не всегда в удобном для нас виде. -Поэтому мы создали два его наследника: CSVHandler и JSONHandler +'''Задания: + 1. Переопределите метод is_available в классе AlcoholProduct с использованием super() + 2. is_available у AlcoholProduct должен возвращать False если сейчас часы между 5 утра и 11 вечера. + Для определения текущего часа можно использовать datetime.now().hour + 3. Создайте экземпляр класса AlcoholProduct и проверьте, можно ли сейчас продавать алкоголь. +''' +from datetime import datetime -Задания: - 1. Переопределите метод read у CSVHandler и JSONHandler - 2. Метод read у JSONHandler должен возвращать словарь. Для этого используйте модуль встроенный модуль json - 3. Метод read у CSVHandler должен возвращать список словарей. Для этого используйте модуль встроенный модуль csv - 4. Создайте экземпляры каждого из трех классов. - С помощью экземпляра FileHandler прочитайте и распечатайте содержимое файла text.txt - С помощью экземпляра JSONHandler прочитайте и распечатайте содержимое файла recipes.json - С помощью экземпляра CSVHandler прочитайте и распечатайте содержимое файла user_info.csv -""" -import csv -import json +class Product: + def __init__(self, title, price, stock_quantity): + self.title = title + self.price = price + self.stock_quantity = stock_quantity + def get_discounted_price(self, discount_percentage): + return self.price * (1 - discount_percentage / 100) -class FileHandler: - def __init__(self, filename): - self.filename = filename + def is_available(self): + return self.stock_quantity > 0 - def read(self): - with open(self.filename, 'r', encoding='utf-8') as file: - return file.read() - - -class JSONHandler(FileHandler): - def __init__(self, filename): - super().__init__(filename) - def read(self): - with open(self.filename, 'r') as file: - return json.load(file) - - - - -class CSVHandler(FileHandler): - def __init__(self, filename): - super().__init__(filename) - def read(self): - with open(self.filename, 'r', encoding='utf-8') as file: - csv_reader = csv.DictReader(file) - data = [row for row in csv_reader] - return data +class AlcoholProduct(Product): + def __init__(self, title, price, stock_quantity): + super().__init__(title, price, stock_quantity) + def is_available(self): + super().is_available() + if 5 < datetime.now().hour < 24: + return False + else: + return f'Пейте на здоровье' if __name__ == '__main__': - hand = FileHandler('text.txt') - print(hand.read()) - - jsn = JSONHandler('recipes.json') - print(jsn.read()) + product = Product('teqila', 1000, 15) + print(product.get_discounted_price(0.75)) + print(product.is_available()) - cs = CSVHandler('user_info.csv') - print(cs.read()) + alco = AlcoholProduct('teqila', 1000, 15) + print(alco.is_available()) From 742690c02f2c457806a617b3b40a37d59e02201b Mon Sep 17 00:00:00 2001 From: RusssianNightmare <123409770+RusssianNightmare@users.noreply.github.com> Date: Sun, 29 Mar 2026 23:32:16 +0300 Subject: [PATCH 15/15] Update b_food_product.py --- level_4/b_food_product.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/level_4/b_food_product.py b/level_4/b_food_product.py index 993325a..50b63a2 100644 --- a/level_4/b_food_product.py +++ b/level_4/b_food_product.py @@ -26,8 +26,25 @@ def is_available(self): class FoodProduct(Product): - pass # код писать тут + def __init__(self, title, quantity, expiration_date): + super().__init__(title, quantity) + self.expiration_date = expiration_date + + def get_full_info(self): + return super().get_full_info() + + def is_available(self): + today = datetime.today() + if self.expiration_date < today.strftime('%d %m %Y'): + return False, super().is_available() + if __name__ == '__main__': - pass # код писать тут + prod = Product('milk', 15) + print(prod.get_full_info()) + print(prod.is_available()) + + food = FoodProduct('yogurt', 10, '28 03 2026') + print(food.get_full_info()) + print(food.is_available())