From 622609a0c603f6cc19faab105724abce37fd441d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BC=C5=9Fra=20Pehlivanlar?= Date: Tue, 23 Dec 2025 17:38:23 +0300 Subject: [PATCH] Implement custom power and equation functions Added custom power and equation functions with a call counter. --- Week04/funtions_busra_pehlivanlar.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Week04/funtions_busra_pehlivanlar.py diff --git a/Week04/funtions_busra_pehlivanlar.py b/Week04/funtions_busra_pehlivanlar.py new file mode 100644 index 00000000..96e89551 --- /dev/null +++ b/Week04/funtions_busra_pehlivanlar.py @@ -0,0 +1,21 @@ +import sys + +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: + return float((x**a + y**b) / c) + +def fn_w_counter(): + if not hasattr(fn_w_counter, "calls"): + fn_w_counter.calls = 0 + fn_w_counter.callers = {} + + try: + caller_name = sys._getframe(1).f_globals.get('__name__', '__main__') + except: + caller_name = "__main__" + + fn_w_counter.calls += 1 + fn_w_counter.callers[caller_name] = fn_w_counter.callers.get(caller_name, 0) + 1 + + return (fn_w_counter.calls, fn_w_counter.callers)