From 765f69f3551d9649cd69996afab4291fe3b5e88e Mon Sep 17 00:00:00 2001 From: ugur-kurt <119804118+ugur-kurt@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:46:58 +0300 Subject: [PATCH] Add custom power and equation functions with call counter Added custom_power lambda and custom_equation function for mathematical calculations. Implemented a call counter function to track the number of calls made. --- Week04/functions_ugur_kurt.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Week04/functions_ugur_kurt.py diff --git a/Week04/functions_ugur_kurt.py b/Week04/functions_ugur_kurt.py new file mode 100644 index 00000000..64c7ae18 --- /dev/null +++ b/Week04/functions_ugur_kurt.py @@ -0,0 +1,34 @@ +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 equation (x**a + y**b) / c. + + :param x: The base of the first term, positional-only + :type x: int + :param y: The base of the second term, positional-only + :type y: int + :param a: The exponent of the first term + :type a: int + :param b: The exponent of the second term + :type b: int + :param c: The divisor, keyword-only + :type c: int + :return: The result of (x**a + y**b) / c + + """ + + return (x**a + y**b) / c + + +_total_calls = 0 +_calls_by_caller = {} + + +def fn_w_counter() -> (int, dict[str, int]): + + global _total_calls + _total_calls += 1 + _calls_by_caller[__name__] = _calls_by_caller.get(__name__, 0) + 1 + return _total_calls, dict(_calls_by_caller)