From a1b73b358c6807e09fce76b883aab08e0bef81b5 Mon Sep 17 00:00:00 2001 From: YUKSELutku <149325205+YUKSELutku@users.noreply.github.com> Date: Tue, 23 Dec 2025 12:49:35 +0300 Subject: [PATCH] Add custom power and equation functions with counter --- Week04/functions_utku_yuksel.py | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Week04/functions_utku_yuksel.py diff --git a/Week04/functions_utku_yuksel.py b/Week04/functions_utku_yuksel.py new file mode 100644 index 00000000..07eecdbe --- /dev/null +++ b/Week04/functions_utku_yuksel.py @@ -0,0 +1,42 @@ +import inspect + +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: + """ + Computes the result of the equation (x**a + y**b) / c. + + :param x: The first base integer + :type x: int + :param y: The second base integer + :type y: int + :param a: The first exponent + :type a: int + :param b: The second exponent + :type b: int + :param c: The divisor + :type c: int + :return: The result of the equation as a float + :rtype: float + """ + return (x**a + y**b) / c + +def fn_w_counter() -> tuple[int, dict]: + if not hasattr(fn_w_counter, 'total_calls'): + fn_w_counter.total_calls = 0 + fn_w_counter.caller_counts = {} + + fn_w_counter.total_calls += 1 + + try: + frame = inspect.currentframe().f_back + caller_name = frame.f_globals['__name__'] + except (AttributeError, KeyError): + caller_name = 'unknown' + + if caller_name in fn_w_counter.caller_counts: + fn_w_counter.caller_counts[caller_name] += 1 + else: + fn_w_counter.caller_counts[caller_name] = 1 + + return fn_w_counter.total_calls, fn_w_counter.caller_counts