From 18fb07e76877a05e03e6a7261bb165a6dca6d93a Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 21 Sep 2024 11:22:22 +0000 Subject: [PATCH 01/14] asd --- lec_1_dynamic_fields.py | 17 +++++++++++++++++ lec_1_static_fields.py | 9 +++++++++ lec_1_user_fields.py | 33 +++++++++++++++++++++++++++++++++ less_1.py | 0 4 files changed, 59 insertions(+) create mode 100644 lec_1_dynamic_fields.py create mode 100644 lec_1_static_fields.py create mode 100644 lec_1_user_fields.py create mode 100644 less_1.py diff --git a/lec_1_dynamic_fields.py b/lec_1_dynamic_fields.py new file mode 100644 index 0000000..09ee50a --- /dev/null +++ b/lec_1_dynamic_fields.py @@ -0,0 +1,17 @@ +import random + +class Ball: + def __init__(self, mass): + self.mass = mass + self.image = "NMX" + + def get_random_model(self): + cj = ['Nike', 'Adidas', 'Reebok', 'Puma', 'Converse'] + + res = random.choice(cj) + return res + +ball = Ball(10) + +print(ball.mass, ball.image) +print(ball.get_random_model()) \ No newline at end of file diff --git a/lec_1_static_fields.py b/lec_1_static_fields.py new file mode 100644 index 0000000..282e459 --- /dev/null +++ b/lec_1_static_fields.py @@ -0,0 +1,9 @@ + + +class Ball: + pass + + + +print(dir(Ball)) + diff --git a/lec_1_user_fields.py b/lec_1_user_fields.py new file mode 100644 index 0000000..86dd580 --- /dev/null +++ b/lec_1_user_fields.py @@ -0,0 +1,33 @@ +import random + +class Ball: + def __init__(self, mass): + self.mass = mass + self.image = "NMX" + self.x, self.y = 0, 0 + + def get_random_model(self): + cj = ['Nike', 'Adidas', 'Reebok', 'Puma', 'Converse'] + + res = random.choice(cj) + return res + + def get_random_num(self, max_length): + return random.randint(1, max_length) + + def drop(self): + self.y += 1 + return 'Я подбросился на', self.y + def kick(self): + self.x += 1 + return "Меня пнули на ", self.x + +ball = Ball(10) + +print(ball.mass, ball.image) +print(ball.get_random_model()) + +print(ball.get_random_num(max_length=100)) +for _ in range(10): + print(ball.drop(), ball.y) + print(ball.x, ball.y) diff --git a/less_1.py b/less_1.py new file mode 100644 index 0000000..e69de29 From fea65970afce04d779aac3aa085b22de501e84f8 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 21 Sep 2024 12:10:03 +0000 Subject: [PATCH 02/14] 123 --- lab_1_task_1.py | 33 +++++++++++++++++++++++++++++ lab_1_task_2.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 lab_1_task_1.py create mode 100644 lab_1_task_2.py diff --git a/lab_1_task_1.py b/lab_1_task_1.py new file mode 100644 index 0000000..6a79acc --- /dev/null +++ b/lab_1_task_1.py @@ -0,0 +1,33 @@ +class SchoolDiary: + def __init__(self, subject, student, grade_list): + self.subject = subject + self.student = student + self.grade_list = grade_list + + def grade(self, num): + if num < 1 or num > 5: + return "Недопустимое число! \nПожалуйста, введите число от 1 до 5." + return self.grade_list.append(num) + + def final_grade(self): + sum_grade = sum(self.grade_list) + + res = sum_grade / len(self.grade_list) + print(f"Окончательная оценка: {res}") + + + def printer(self): + print(f"Ученик: {self.student}") + print(f"Предмет: {self.subject}") + print(f"Оценки: {self.grade_list}") + + + +obj = SchoolDiary("Информатика", "Иванов Иван", [4, 5, 5, 4, 5]) + +obj.grade(3) + +obj.printer() +obj.final_grade() + + \ No newline at end of file diff --git a/lab_1_task_2.py b/lab_1_task_2.py new file mode 100644 index 0000000..6f27335 --- /dev/null +++ b/lab_1_task_2.py @@ -0,0 +1,56 @@ +class Pyramid: + + total_h = 0 + def __init__(self, max_h, bricks_count=0): + self.bricks = max_h + self.bricks_count = bricks_count + + def add_bricks(self, num): + + try: + if num <= 5: + self.total_h += 1 + elif num > 5: + print("Нельзя добавить более 5 кирпичей! \nПостройка разрушена!") + except Exception as e: + print("Ошибка:", e) + + + self.bricks_count += num + + def get_height(self): + print(f"Высота пирамиды: {self.total_h}") + + def is_done(self): + self.res = (self.max_h / self.total_h) * 100 + if self.res == 100: + exit(0) + return self.res + + +class Builder: + def __init__(self, bricks, my_pyramid): + self.bricks = bricks + self.my_pyramid = Pyramid(15) + + def buy_bricks(self): + if self.bricks <= 0: + bricks += 5 + + def build_pyramid(self, n ): + if self.bricks >= n: + self.bricks -= n + self.my_pyramid.add_bricks(n) + else: + print("Недостаточно кирпичей!") + + + + self.my_pyramid.add_bricks(self.bricks) + self.my_pyramid.get_height() + + def work_day(self): + self.build_pyramid(5) + self.my_pyramid.is_done() + self.buy_bricks() + From f22f1d05d09ebf3d1a6d72997ccb4280f173188e Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:06:09 +0000 Subject: [PATCH 03/14] =?UTF-8?q?=D1=84=D1=8B=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab_1_task_2.py | 93 ++++++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 35 deletions(-) diff --git a/lab_1_task_2.py b/lab_1_task_2.py index 6f27335..6e8b141 100644 --- a/lab_1_task_2.py +++ b/lab_1_task_2.py @@ -1,56 +1,79 @@ class Pyramid: - - total_h = 0 - def __init__(self, max_h, bricks_count=0): - self.bricks = max_h - self.bricks_count = bricks_count + def __init__(self, max_h): + self.max_h = max_h + self.bricks_count = 0 + self.total_h = 0 def add_bricks(self, num): - - try: - if num <= 5: - self.total_h += 1 - elif num > 5: - print("Нельзя добавить более 5 кирпичей! \nПостройка разрушена!") - except Exception as e: - print("Ошибка:", e) - - - self.bricks_count += num + while num > 0: + required_bricks = self.max_h - self.total_h + + if self.total_h < self.max_h: + if num >= required_bricks: + num -= required_bricks + self.bricks_count += required_bricks + self.total_h += 1 + else: + self.bricks_count += num + break + else: + break def get_height(self): - print(f"Высота пирамиды: {self.total_h}") + return self.total_h # Возвращаем текущую высоту пирамиды def is_done(self): - self.res = (self.max_h / self.total_h) * 100 - if self.res == 100: - exit(0) - return self.res - + total_bricks = (self.max_h * (self.max_h + 1)) // 2 + res_bricks = (self.bricks_count / total_bricks) * 100 + return res_bricks + class Builder: - def __init__(self, bricks, my_pyramid): + def __init__(self, bricks): self.bricks = bricks self.my_pyramid = Pyramid(15) def buy_bricks(self): - if self.bricks <= 0: - bricks += 5 + self.bricks += 5 + print(f"Куплено 5 кирпичей. Теперь у строителя {self.bricks} кирпичей.") - def build_pyramid(self, n ): + def build_pyramid(self, n): if self.bricks >= n: self.bricks -= n - self.my_pyramid.add_bricks(n) + return n else: print("Недостаточно кирпичей!") - + return 0 + + def work_day(self): + needed_bricks = min(5, self.bricks + 5) # Пытаемся использовать до 5 кирпичей + added_bricks = self.build_pyramid(needed_bricks) + + + if added_bricks > 0: + self.my_pyramid.add_bricks(added_bricks) + + print(f"Строили пирамиду: добавлено {added_bricks} кирпичей.") + print(f"Остаток кирпичей у строителя: {self.bricks}.") + + + readiness = self.my_pyramid.is_done() + print(f"Готовность пирамиды: {readiness:.2f}%.") + print(f"Высота пирамиды: {self.my_pyramid.get_height()}.") + + if readiness == 100: + print("Пирамида завершена!") + exit(0) + + + if added_bricks == 0: + self.buy_bricks() - self.my_pyramid.add_bricks(self.bricks) - self.my_pyramid.get_height() +b = Builder(13) +day = 1 - def work_day(self): - self.build_pyramid(5) - self.my_pyramid.is_done() - self.buy_bricks() - +while True: + print(f"День {day}:") + b.work_day() + day += 1 \ No newline at end of file From ac9677096821e6ad08fe1f06cedc635bc0790daa Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:58:37 +0000 Subject: [PATCH 04/14] asd --- lab_1_task_3.py | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lab_1_task_3.py diff --git a/lab_1_task_3.py b/lab_1_task_3.py new file mode 100644 index 0000000..37a8248 --- /dev/null +++ b/lab_1_task_3.py @@ -0,0 +1,80 @@ +class Puppy: + states = ["Болеет", "Выздоравливает", "Здоров"] + + def __init__(self, index): + self.index = index + self.state = self.states[0] + + def get_treatment(self): + if self.state == self.states[0]: + self.state = self.states[1] + elif self.state == self.states[1]: + self.state = self.states[2] + else: + return 0 + + def is_healthy(self): + if self.state == self.states[2]: + return "Щенок здоров" + + +class Dog: + def __init__(self, puppy_count): + self.puppies = [Puppy(i) for i in range(1, puppy_count + 1)] + + def health_all(self): + for puppy in self.puppies: + puppy.get_treatment() + + def all_are_healthy(self): + for puppy in self.puppies: + if puppy.is_healthy(): + continue + else: + return False + return True + + def give_away_all(self): + if self.all_are_healthy(): + self.puppies.clear() + print("Все щенки присроены в хорошие руки") + else: + print("Не все щенки здоровы") + + +class Vet: + def __init__(self, name, dog): + self.name = name + self.dog = dog + + def work(self): + self.dog.health_all() + print(f"Все щенки получили лечение от {self.name}") + def care(self): + if self.dog.all_are_healthy(): + print("Все щенки здоровы") + self.dog.give_away_all() + else: + print("Есть нездоровые щенки") + + def knowledge_base(self): + print("База знаний ветеринарской клиники") + print("1. Проводить регулярные осмотры щенков") + print("2. Провести лечение нездоровых щенков") + print("3. Выдать доказательства здоровья") + print("4. Пристроить щенков в хорошие руки") + + + +dog = Dog(puppy_count=5) + +vet = Vet("Иванов Иван", dog) + +vet.knowledge_base() +vet.work() +vet.care() +dog.give_away_all() +vet.work() +vet.care() + + From 708536014dd15c85773c04cb212b0b45addead45 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 28 Sep 2024 12:04:39 +0000 Subject: [PATCH 05/14] asd --- lab_1_task_1.py | 10 +++++----- lab_1_task_2.py | 32 +++++++++++++++++++++----------- lab_1_task_3.py | 17 +++++++++-------- lab_1_task_4,py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 lab_1_task_4,py diff --git a/lab_1_task_1.py b/lab_1_task_1.py index 6a79acc..b1987d4 100644 --- a/lab_1_task_1.py +++ b/lab_1_task_1.py @@ -22,12 +22,12 @@ def printer(self): print(f"Оценки: {self.grade_list}") +if __name__ == '__main__': + obj = SchoolDiary("Информатика", "Иванов Иван", [4, 5, 5, 4, 5]) -obj = SchoolDiary("Информатика", "Иванов Иван", [4, 5, 5, 4, 5]) + obj.grade(3) -obj.grade(3) - -obj.printer() -obj.final_grade() + obj.printer() + obj.final_grade() \ No newline at end of file diff --git a/lab_1_task_2.py b/lab_1_task_2.py index 6e8b141..228a7fa 100644 --- a/lab_1_task_2.py +++ b/lab_1_task_2.py @@ -5,22 +5,29 @@ def __init__(self, max_h): self.total_h = 0 def add_bricks(self, num): - while num > 0: + while num > 0 and self.total_h < self.max_h: required_bricks = self.max_h - self.total_h + if self.total_h < self.max_h: if num >= required_bricks: num -= required_bricks self.bricks_count += required_bricks self.total_h += 1 + print('123') + else: self.bricks_count += num break else: break + self.get_height() def get_height(self): - return self.total_h # Возвращаем текущую высоту пирамиды + # Выводим текущую высоту пирамиды + + print(f"Высота пирамиды: {self.total_h}.") + def is_done(self): total_bricks = (self.max_h * (self.max_h + 1)) // 2 @@ -31,6 +38,7 @@ def is_done(self): class Builder: def __init__(self, bricks): self.bricks = bricks + self.day = 1 self.my_pyramid = Pyramid(15) def buy_bricks(self): @@ -46,20 +54,22 @@ def build_pyramid(self, n): return 0 def work_day(self): - needed_bricks = min(5, self.bricks + 5) # Пытаемся использовать до 5 кирпичей + needed_bricks = min(5, self.bricks + 5) added_bricks = self.build_pyramid(needed_bricks) if added_bricks > 0: self.my_pyramid.add_bricks(added_bricks) + print(f"День {self.day}.") print(f"Строили пирамиду: добавлено {added_bricks} кирпичей.") print(f"Остаток кирпичей у строителя: {self.bricks}.") + self.my_pyramid.get_height() # Выводим текущую высоту пирамиды readiness = self.my_pyramid.is_done() print(f"Готовность пирамиды: {readiness:.2f}%.") - print(f"Высота пирамиды: {self.my_pyramid.get_height()}.") + if readiness == 100: print("Пирамида завершена!") @@ -68,12 +78,12 @@ def work_day(self): if added_bricks == 0: self.buy_bricks() + + self.day += 1 +if __name__ == '__main__': + b = Builder(13) -b = Builder(13) -day = 1 - -while True: - print(f"День {day}:") - b.work_day() - day += 1 \ No newline at end of file + while True: + b.work_day() + \ No newline at end of file diff --git a/lab_1_task_3.py b/lab_1_task_3.py index 37a8248..797cf60 100644 --- a/lab_1_task_3.py +++ b/lab_1_task_3.py @@ -65,16 +65,17 @@ def knowledge_base(self): print("4. Пристроить щенков в хорошие руки") +if __name__ == '__main__': -dog = Dog(puppy_count=5) + dog = Dog(puppy_count=5) -vet = Vet("Иванов Иван", dog) + vet = Vet("Иванов Иван", dog) -vet.knowledge_base() -vet.work() -vet.care() -dog.give_away_all() -vet.work() -vet.care() + vet.knowledge_base() + vet.work() + vet.care() + dog.give_away_all() + vet.work() + vet.care() diff --git a/lab_1_task_4,py b/lab_1_task_4,py new file mode 100644 index 0000000..0171fb2 --- /dev/null +++ b/lab_1_task_4,py @@ -0,0 +1,46 @@ +class Supplier: + + def __init__(self, name, location): + self.name = name + self.location = location + self.products = ['PC', 'AK-47', 'NASA DRON'] + + def add_product(self, product): + self.products.append(product) + + def get_info(self): + return f'Supplier Name: {self.name}, Location: {self.location}, Products: {self.products}' + +class Customer: + + def __init__(self, name, address): + self.name = name + self.address = address + self.orders = [] + + def buy_order(self, order): + self.orders.append(order) + + def get_info(self): + return f'Customer Name: {self.name}, Address: {self.address}, Orders: {self.orders}' + +class VPN: + def __init__(self): + self.suppliers_info = [] + self.customers_info = [] + + def hide(self): + return "НЕИЗВЕСТНО" + def get_location(self): + print("ДАННЫХ НЕ НАЙДЕНО!") + + +if __name__ == "__main__": + vpn = VPN() + supplier1 = Supplier('Supplier MRX', location=vpn.hide()) + customer = Customer('Supplier KTX', address='Moscow, Moscow City') + customer.buy_order(supplier1.products[2]) + + print(supplier1.get_info()) + print(customer.get_info()) + From f7aea2d8eb31adcf2f12d00414feacdd5c9b20f2 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 5 Oct 2024 10:29:31 +0000 Subject: [PATCH 06/14] asd --- lab_1_task_2.py | 5 ++++- lab_1_task_4,py => lab_1_task_4.py | 0 2 files changed, 4 insertions(+), 1 deletion(-) rename lab_1_task_4,py => lab_1_task_4.py (100%) diff --git a/lab_1_task_2.py b/lab_1_task_2.py index 228a7fa..7bcf159 100644 --- a/lab_1_task_2.py +++ b/lab_1_task_2.py @@ -3,10 +3,13 @@ def __init__(self, max_h): self.max_h = max_h self.bricks_count = 0 self.total_h = 0 + + + self.bricks_rows = [i for i in range(self.max_h, 0, -1)] def add_bricks(self, num): while num > 0 and self.total_h < self.max_h: - required_bricks = self.max_h - self.total_h + required_bricks = self.max_h - self.total_h if self.total_h < self.max_h: diff --git a/lab_1_task_4,py b/lab_1_task_4.py similarity index 100% rename from lab_1_task_4,py rename to lab_1_task_4.py From 572b647550c02421a2e270b2b68d1dcf8b2c6cb6 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 5 Oct 2024 11:45:11 +0000 Subject: [PATCH 07/14] lkasdhpoashd --- lab_1_task_2.py | 40 +++++++++++++++++++++------------------- lab_1_task_4.py | 11 +++++++---- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lab_1_task_2.py b/lab_1_task_2.py index 7bcf159..d8f7f54 100644 --- a/lab_1_task_2.py +++ b/lab_1_task_2.py @@ -3,28 +3,31 @@ def __init__(self, max_h): self.max_h = max_h self.bricks_count = 0 self.total_h = 0 - + self.bricks_in_current_row = 0 self.bricks_rows = [i for i in range(self.max_h, 0, -1)] + self.all_bricks = sum(self.bricks_rows) + print(self.all_bricks) def add_bricks(self, num): - while num > 0 and self.total_h < self.max_h: - required_bricks = self.max_h - self.total_h - - - if self.total_h < self.max_h: - if num >= required_bricks: - num -= required_bricks - self.bricks_count += required_bricks - self.total_h += 1 - print('123') - - else: - self.bricks_count += num - break + self.bricks_count += num + while self.total_h < self.max_h: + bricks_in_rows = self.bricks_rows[self.total_h] + if self.bricks_in_current_row + num >= bricks_in_rows: + num -= (bricks_in_rows - self.bricks_in_current_row) + self.bricks_in_current_row = 0 + self.total_h += 1 else: + self.bricks_in_current_row += num break - self.get_height() + + if num > 0 and self.total_h < self.max_h: + self.bricks_in_current_row += num + + if self.total_h >= self.max_h: + print('Пирамида достигла максимальной высоты!') + + def get_height(self): # Выводим текущую высоту пирамиды @@ -33,8 +36,7 @@ def get_height(self): def is_done(self): - total_bricks = (self.max_h * (self.max_h + 1)) // 2 - res_bricks = (self.bricks_count / total_bricks) * 100 + res_bricks = self.bricks_count / self.all_bricks * 100 return res_bricks @@ -74,7 +76,7 @@ def work_day(self): print(f"Готовность пирамиды: {readiness:.2f}%.") - if readiness == 100: + if readiness >= 100: print("Пирамида завершена!") exit(0) diff --git a/lab_1_task_4.py b/lab_1_task_4.py index 0171fb2..276b05e 100644 --- a/lab_1_task_4.py +++ b/lab_1_task_4.py @@ -1,9 +1,11 @@ +import random + class Supplier: def __init__(self, name, location): self.name = name self.location = location - self.products = ['PC', 'AK-47', 'NASA DRON'] + self.products = ['BTC', 'ETH', 'TETHER_USDT'] def add_product(self, product): self.products.append(product) @@ -30,15 +32,16 @@ def __init__(self): self.customers_info = [] def hide(self): - return "НЕИЗВЕСТНО" + address = ['RUSSIA, MOSCOW', 'FRANCE, PARIS', 'USA, Los Angeles'] + return random.choice(address) def get_location(self): print("ДАННЫХ НЕ НАЙДЕНО!") if __name__ == "__main__": vpn = VPN() - supplier1 = Supplier('Supplier MRX', location=vpn.hide()) - customer = Customer('Supplier KTX', address='Moscow, Moscow City') + supplier1 = Supplier('Supplier ER', location=vpn.hide()) + customer = Customer('Supplier KTX', address='Moscow, Moscow City, tower 1') customer.buy_order(supplier1.products[2]) print(supplier1.get_info()) From 239310d6a3a55ff3f2ead7ac40948b34e6b2f934 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Fri, 25 Oct 2024 18:54:44 +0200 Subject: [PATCH 08/14] Create lab_2_task_1.py --- lab_2_task_1.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lab_2_task_1.py diff --git a/lab_2_task_1.py b/lab_2_task_1.py new file mode 100644 index 0000000..00ef9ca --- /dev/null +++ b/lab_2_task_1.py @@ -0,0 +1,15 @@ +def wrapper_function(num): + def ad(func): + def sum_of_two_num(num1): + print(num + num1) + return func() + return sum_of_two_num + return ad + +@wrapper_function(1) +def send_num(): + print("Sending") + + +send_num(3) + From 09fd27de1f163d04c2de6ac87a75c2ad3f88da25 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 2 Nov 2024 18:58:44 +0200 Subject: [PATCH 09/14] Create lab_2_task2.py --- lab_2_task2.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 lab_2_task2.py diff --git a/lab_2_task2.py b/lab_2_task2.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lab_2_task2.py @@ -0,0 +1 @@ + From bb2df90cde8e8a19c34bac3ca98243136565da74 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 2 Nov 2024 19:02:48 +0200 Subject: [PATCH 10/14] Update lab_2_task2.py --- lab_2_task2.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lab_2_task2.py b/lab_2_task2.py index 8b13789..7d7272a 100644 --- a/lab_2_task2.py +++ b/lab_2_task2.py @@ -1 +1,22 @@ +def operation_decorator(func): + def wrapper(x, y, operation): + if operation == '+': + return func(x, y, lambda x, y: x + y) + elif operation == '-': + return func(x, y, lambda x, y: x - y) + elif operation == '*': + return func(x, y, lambda x, y: x * y) + elif operation == '/': + if y != 0: + return func(x, y, lambda x, y: x / y) + else: + return "Error: Division by zero" + return wrapper + +@operation_decorator +def calculate(x, y, operation_func): + return operation_func(x, y) + +result = calculate(5, 3, '+') +print(result) From 2e189e16b2282e0ecdb4baad7c30d5889f28c034 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 16 Nov 2024 11:19:41 +0200 Subject: [PATCH 11/14] Create lab_2_task3.py --- lab_2_task3.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 lab_2_task3.py diff --git a/lab_2_task3.py b/lab_2_task3.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lab_2_task3.py @@ -0,0 +1 @@ + From 357700435f2795338816f5b7de103a1e401ee877 Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 16 Nov 2024 11:24:46 +0200 Subject: [PATCH 12/14] Update lab_2_task3.py --- lab_2_task3.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lab_2_task3.py b/lab_2_task3.py index 8b13789..49ddee0 100644 --- a/lab_2_task3.py +++ b/lab_2_task3.py @@ -1 +1,20 @@ + +import math +def debug(func): + def wrapper(*args, **kwargs): + print(f"Calling {func.__name__} with arguments {args}") + + result = func(*args, **kwargs) + + print(f'{func.__name__} returned: {result}') + + return result + + return wrapper + +@debug +def sq(x, y): + return math.sqrt(x * y) + +result = sq(3, 3) From ef2d17401fab65718a7d1bfc99109987fdaa980c Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 16 Nov 2024 11:37:11 +0200 Subject: [PATCH 13/14] Create lab_2_task4.py --- lab_2_task4.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 lab_2_task4.py diff --git a/lab_2_task4.py b/lab_2_task4.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lab_2_task4.py @@ -0,0 +1 @@ + From defb23eae05c5d2dcca7aaf16ee7a7f607dd756f Mon Sep 17 00:00:00 2001 From: moaxgetsu <65217332+Nmxxxxx@users.noreply.github.com> Date: Sat, 16 Nov 2024 11:51:17 +0200 Subject: [PATCH 14/14] Update lab_2_task4.py --- lab_2_task4.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lab_2_task4.py b/lab_2_task4.py index 8b13789..2b5dff6 100644 --- a/lab_2_task4.py +++ b/lab_2_task4.py @@ -1 +1,29 @@ + +class Planet: + def __init__(self): + self.radius = 12.3 + + self._mask = 2 + + @classmethod + def get_radius(self, cls): + return cls.radius + + + @property + def mask(self): + return self._mask + + + @staticmethod + def _print_info(self): + print(f"Planet radius: {self.radius}") + print(f"Planet mask: {self._mask}") + + + +r = Planet() +print(r.get_radius(cls=r)) +print(r.mask) +print(r._print_info(r))