From 80c4985052d27cc6bf2ebf695fbcc7038eeb3996 Mon Sep 17 00:00:00 2001 From: BatuhanAyyildizz <114678625+BatuhanAyyildizz@users.noreply.github.com> Date: Fri, 25 Oct 2024 22:03:59 +0300 Subject: [PATCH] Create functions_batuhan_ayyildiz.py --- Week04/functions_batuhan_ayyildiz.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Week04/functions_batuhan_ayyildiz.py diff --git a/Week04/functions_batuhan_ayyildiz.py b/Week04/functions_batuhan_ayyildiz.py new file mode 100644 index 00000000..caf59399 --- /dev/null +++ b/Week04/functions_batuhan_ayyildiz.py @@ -0,0 +1,20 @@ + +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: + return (x ** a + y ** b) / c + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "count"): + setattr(fn_w_counter, "count", 0) + setattr(fn_w_counter, "caller_dict", {}) + + fn_w_counter.count += 1 + caller = __name__ + + if caller not in fn_w_counter.caller_dict: + fn_w_counter.caller_dict[caller] = 0 + + fn_w_counter.caller_dict[caller] += 1 + + return int(fn_w_counter.count), dict(fn_w_counter.caller_dict)