From 67ef3abf68b75051d2b3cfba718017be19a40ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rozerin=20Ya=C5=9Far?= Date: Wed, 18 Nov 2026 19:17:04 +0300 Subject: [PATCH 1/2] Add function to calculate pyramid height from blocks --- Week03/pyramid_rozerin_yasar.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Week03/pyramid_rozerin_yasar.py diff --git a/Week03/pyramid_rozerin_yasar.py b/Week03/pyramid_rozerin_yasar.py new file mode 100644 index 00000000..1ed5b01d --- /dev/null +++ b/Week03/pyramid_rozerin_yasar.py @@ -0,0 +1,8 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + needed_block = 1 + while number_of_blocks >= needed_block: + number_of_blocks -= needed_block + height += 1 + needed_block += 1 + return height From 49d5e55f0dca124063526b0d31a03970d637055b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rozerin=20Ya=C5=9Far?= Date: Wed, 18 Nov 2026 19:25:39 +0300 Subject: [PATCH 2/2] Add custom power, equation functions, and call counter Defines custom power and equation functions along with a call counter. --- Week04/decorators_rozerin_yasar.py | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Week04/decorators_rozerin_yasar.py diff --git a/Week04/decorators_rozerin_yasar.py b/Week04/decorators_rozerin_yasar.py new file mode 100644 index 00000000..7272dbd6 --- /dev/null +++ b/Week04/decorators_rozerin_yasar.py @@ -0,0 +1,42 @@ +import inspect + + + +custom_power = lambda x=0, /, e=1: x ** e + + + +def custom_equation( + x: int = 0, + y: int = 0, + /, + a: int = 1, + b: int = 1, + *, + c: int = 1, +) -> float: + """ + Calculates the value of (x**a + y**b) / c. + + :param x: Base of the first term (positional-only) + :param y: Base of the second term (positional-only) + :param a: Exponent of x (positional-or-keyword) + :param b: Exponent of y (positional-or-keyword) + :param c: Divisor (keyword-only) + :return: Result of (x**a + y**b) / c as a float + """ + return (x ** a + y ** b) / c + + + +def fn_w_counter() -> tuple[int, dict[str, int]]: + if not hasattr(fn_w_counter, "total_calls"): + fn_w_counter.total_calls = 0 + fn_w_counter.callers = {} + + caller_name = inspect.currentframe().f_back.f_globals.get("__name__", "__main__") + + fn_w_counter.total_calls += 1 + fn_w_counter.callers[caller_name] = fn_w_counter.callers.get(caller_name, 0) + 1 + + return fn_w_counter.total_calls, fn_w_counter.callers