From 8ac0ee2e48acf16e53135904b43b567ccd774d3c Mon Sep 17 00:00:00 2001 From: ysnsoytas <163600373+ysnsoytas@users.noreply.github.com> Date: Wed, 7 Jan 2026 19:22:12 +0300 Subject: [PATCH] Implement custom power, equation, and call counter functions Added functions for custom power, equation, and call counter. --- Week04/functions_yasin_soytas.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Week04/functions_yasin_soytas.py diff --git a/Week04/functions_yasin_soytas.py b/Week04/functions_yasin_soytas.py new file mode 100644 index 00000000..9bbed1b7 --- /dev/null +++ b/Week04/functions_yasin_soytas.py @@ -0,0 +1,31 @@ +# ---------- custom_power ---------- + +custom_power = lambda x, e=1: x ** e + + +# ---------- custom_equation ---------- + +def custom_equation(x, y=0, *, a=0, b=1, c=1) -> float: + """ + Computes the equation: (x**a + y**b) / c + """ + return (x ** a + y ** b) / c + + +# ---------- fn_w_counter ---------- + +def fn_w_counter(): + total_calls = 0 + callers = {} + + def inner(): + nonlocal total_calls + total_calls += 1 + + caller_name = __name__ + callers[caller_name] = callers.get(caller_name, 0) + 1 + + return total_calls, callers + + return inner +