From 9b669cdfe51337f129f4f60e2c4758514f065fd5 Mon Sep 17 00:00:00 2001 From: Kerimcan Dede Date: Fri, 30 Oct 2026 05:19:49 +0300 Subject: [PATCH 1/2] Implement custom power and equation functions Added custom power and equation functions with call counter. --- Week04/functions_kerimcan_dede.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Week04/functions_kerimcan_dede.py diff --git a/Week04/functions_kerimcan_dede.py b/Week04/functions_kerimcan_dede.py new file mode 100644 index 00000000..12e17d7a --- /dev/null +++ b/Week04/functions_kerimcan_dede.py @@ -0,0 +1,27 @@ +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: + """ + This function does arithmetic opearations. + + :param1: first number to be exponantiated + :param2: second number to be exponantiated + :param3: power of the first number + :param4: power of the second number + :param5: divisor of sum of exponantiated numbers + + :result: division the sum of exponantiated numbers + """ + return (x**a + y**b) / c + +call_counter = 0 +caller_dict = {} +def fn_w_counter() -> (int, dict): + caller = __name__ + global call_counter + call_counter += 1 + if caller in caller_dict: + caller_dict[caller] += 1 + else: + caller_dict[caller] = 1 + return call_counter, caller_dict From 011f3322e78f1cee8e5d7be3b4d0848b43ace0ac Mon Sep 17 00:00:00 2001 From: Kerimcan Dede Date: Fri, 30 Oct 2026 05:23:19 +0300 Subject: [PATCH 2/2] Fix docstring and update function return type --- Week04/functions_kerimcan_dede.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week04/functions_kerimcan_dede.py b/Week04/functions_kerimcan_dede.py index 12e17d7a..16bf3bc1 100644 --- a/Week04/functions_kerimcan_dede.py +++ b/Week04/functions_kerimcan_dede.py @@ -10,13 +10,13 @@ def custom_equation(x: int=0, y: int=0, /, a: int=1, b: int=1, *, c: int=1) -> f :param4: power of the second number :param5: divisor of sum of exponantiated numbers - :result: division the sum of exponantiated numbers + :return: division the sum of exponantiated numbers """ return (x**a + y**b) / c call_counter = 0 caller_dict = {} -def fn_w_counter() -> (int, dict): +def fn_w_counter() -> (int, dict[str, int]): caller = __name__ global call_counter call_counter += 1