From 219486f8469aaea7e8b746a728dee00746845ec9 Mon Sep 17 00:00:00 2001 From: beytullaharslannn <151189674+beytullaharslannn@users.noreply.github.com> Date: Tue, 20 Oct 2026 13:14:14 +0300 Subject: [PATCH] Add custom functions for power and counting calls Beytullah Arslan Added custom_power lambda and custom_equation function to compute a specific formula. Implemented fn_w_counter to track function calls. --- Week04/functions_beytullah_arslan.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Week04/functions_beytullah_arslan.py diff --git a/Week04/functions_beytullah_arslan.py b/Week04/functions_beytullah_arslan.py new file mode 100644 index 00000000..b1133644 --- /dev/null +++ b/Week04/functions_beytullah_arslan.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: + """ + Calculate the custom equation (x**a + y**b) / c. + + :param x: first base + :param y: second base + :param a: first exponent + :param b: second exponent + :param c: divisor + :return: the computed float result + """ + return (x**a + y**b) / c + + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter,'call_counter'): + fn_w_counter.call_counter = 0 + fn_w_counter.caller_dict = {} + caller = __name__ + fn_w_counter.call_counter += 1 + if caller in fn_w_counter.caller_dict: + fn_w_counter.caller_dict[caller] += 1 + else: + fn_w_counter.caller_dict[caller] = 1 + return fn_w_counter.call_counter,fn_w_counter.caller_dict