From 7d04ea5009337793cefc679b7540f0cc48d3ebf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20=C3=96zt=C3=BCrk?= <97892689+burakozturk1@users.noreply.github.com> Date: Mon, 6 Jan 2025 21:58:36 +0300 Subject: [PATCH] Create functions_burak_ozturk.py --- Week04/functions_burak_ozturk.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Week04/functions_burak_ozturk.py diff --git a/Week04/functions_burak_ozturk.py b/Week04/functions_burak_ozturk.py new file mode 100644 index 00000000..30c1aae3 --- /dev/null +++ b/Week04/functions_burak_ozturk.py @@ -0,0 +1,28 @@ +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: + """ + Compute a custom equation. + + :param x: Positional-only base for the first term (default: 0) + :param y: Positional-only base for the second term (default: 0) + :param a: Exponent for the first term (default: 1) + :param b: Exponent for the second term (default: 1) + :param c: Divisor, keyword-only (default: 1) + :return: Result of the calculation as a float + """ + return (x**a + y**b) / c + +def fn_w_counter() -> tuple[int, dict]: + """ + Function that tracks how many times it has been called and logs calls by module name. + + :return: A tuple containing the call count and a dictionary of module call statistics. + """ + if not hasattr(fn_w_counter, "counter"): + fn_w_counter.counter = 0 + fn_w_counter.dict = {} + caller_name = __name__ + fn_w_counter.counter += 1 + fn_w_counter.dict[caller_name] = fn_w_counter.dict.get(caller_name, 0) + 1 + return fn_w_counter.counter, fn_w_counter.dict