From d07a05818bab1371eb425da025fb5988219b9ab6 Mon Sep 17 00:00:00 2001 From: dilek <128893136+dilekk1@users.noreply.github.com> Date: Sat, 2 Nov 2024 15:32:31 +0300 Subject: [PATCH 1/2] Create functions_dilek_celebi.py --- Week04/functions_dilek_celebi.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Week04/functions_dilek_celebi.py diff --git a/Week04/functions_dilek_celebi.py b/Week04/functions_dilek_celebi.py new file mode 100644 index 00000000..97f7fb8a --- /dev/null +++ b/Week04/functions_dilek_celebi.py @@ -0,0 +1,25 @@ +from collections import defaultdict + +custom_power = lambda base=0, /, exponent=1: base**exponent + +def custom_formula(x: int = 0, y: int = 0, /, exp_x: int = 1, exp_y: int = 1, *, divisor: int = 1) -> float: + """ + :param x: Positional-only integer base for the equation, default is 0 + :param y: Positional-only integer base for the equation, default is 0 + :param exp_x: Positional-or-keyword integer exponent for x, default is 1 + :param exp_y: Positional-or-keyword integer exponent for y, default is 1 + :param divisor: Keyword-only integer divisor, default is 1 + :return: Result of (x**exp_x + y**exp_y) / divisor as a float + """ + return (x**exp_x + y**exp_y) / divisor + +def function_with_counter() -> (int, dict[str, int]): + if not hasattr(function_with_counter, '_total_calls'): + function_with_counter._total_calls = 0 + function_with_counter._module_calls = defaultdict(int) + + current_module = __name__ + function_with_counter._total_calls += 1 + function_with_counter._module_calls[current_module] += 1 + + return function_with_counter._total_calls, dict(function_with_counter._module_calls) From 9a153e7ae294096944434c1401199abac8e8313c Mon Sep 17 00:00:00 2001 From: dilek <128893136+dilekk1@users.noreply.github.com> Date: Sat, 2 Nov 2024 15:35:39 +0300 Subject: [PATCH 2/2] Update functions_dilek_celebi.py --- Week04/functions_dilek_celebi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/functions_dilek_celebi.py b/Week04/functions_dilek_celebi.py index 97f7fb8a..cf8a178a 100644 --- a/Week04/functions_dilek_celebi.py +++ b/Week04/functions_dilek_celebi.py @@ -18,7 +18,7 @@ def function_with_counter() -> (int, dict[str, int]): function_with_counter._total_calls = 0 function_with_counter._module_calls = defaultdict(int) - current_module = __name__ + current_module = "__name__" function_with_counter._total_calls += 1 function_with_counter._module_calls[current_module] += 1