From c186937e0bab3c0ec981ac41273a358f33436a18 Mon Sep 17 00:00:00 2001 From: furkanustuncan <87567493+furkanustuncan@users.noreply.github.com> Date: Fri, 6 Nov 2026 12:14:21 +0300 Subject: [PATCH] functions_furkan_ustuncan.py --- Week04/functions_furkan_ustuncan.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Week04/functions_furkan_ustuncan.py diff --git a/Week04/functions_furkan_ustuncan.py b/Week04/functions_furkan_ustuncan.py new file mode 100644 index 00000000..ef57818c --- /dev/null +++ b/Week04/functions_furkan_ustuncan.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: + """ + Calculates the result of the equation (x**a + y**b) / c. + + :param x: First base, positional-only + :param y: Second base, positional-only + :param a: Exponent of x + :param b: Exponent of y + :param c: Divisor, keyword-only + :return: Result of (x**a + y**b) / c as a float + """ + for name, value in (("x", x), ("y", y), ("a", a), ("b", b), ("c", c)): + if not isinstance(value, int): + raise TypeError(f"{name} must be an integer") + return (x ** a + y ** b) / c + + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "total"): + fn_w_counter.total = 0 + fn_w_counter.callers = {} + fn_w_counter.total += 1 + fn_w_counter.callers[__name__] = fn_w_counter.callers.get(__name__, 0) + 1 + return fn_w_counter.total, fn_w_counter.callers