From 1b6d69241b8bbe0c65b58613cffe214ee599e356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sultan=20Y=C3=BCksel?= Date: Thu, 19 Nov 2026 09:38:43 +0300 Subject: [PATCH] Implement custom power and equation functions Added custom_power and custom_equation functions along with a counter function. --- Week04/functions_sultan_yuksel.py | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Week04/functions_sultan_yuksel.py diff --git a/Week04/functions_sultan_yuksel.py b/Week04/functions_sultan_yuksel.py new file mode 100644 index 00000000..b3bc5035 --- /dev/null +++ b/Week04/functions_sultan_yuksel.py @@ -0,0 +1,35 @@ +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 calculates the custom equation (x**a + y**b)/c + + :param x: Positional-only x value, defaults to 0 + :type x: int, optional + :param y: Positional-onlyr y value, defaults to 0 + :type y: int, optional + :param a: Positional-or-keyword exponent for x, defaults to 1 + :type a: int, optional + :param b: Positional-or-keyword exponent for y, defaults to 1 + :type b: int, optional + :param c: Keyword-only division of the sum, defaults to 1 + :type c: int, optional + :return: Result of (x**a + y**b)/c + :rtype: float + + ''' + return (x**a + y**b)/c + + +def fn_w_counter() -> tuple[int, dict[str, int]]: + if not hasattr(fn_w_counter, "counter"): + fn_w_counter.counter = 0 + fn_w_counter.callers = {} + fn_w_counter.counter += 1 + if __name__ in fn_w_counter.callers: + fn_w_counter.callers[__name__] += 1 + else: + fn_w_counter.callers = 1 + return fn_w_counter.counter, fn_w_counter.callers +