From d4f9d217013aef0a29c30ab59aa1c11e70987467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eekip=20Yaman=20Arslan?= <155294621+yamanarslan@users.noreply.github.com> Date: Tue, 7 Apr 2026 21:42:56 +0300 Subject: [PATCH] Add custom mathematical functions and counter Added custom_power lambda function and custom_equation function for mathematical operations. Implemented fn_w_counter to count function calls. --- Week04/functions_sekip_yaman_arslan.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Week04/functions_sekip_yaman_arslan.py diff --git a/Week04/functions_sekip_yaman_arslan.py b/Week04/functions_sekip_yaman_arslan.py new file mode 100644 index 00000000..6438b9f4 --- /dev/null +++ b/Week04/functions_sekip_yaman_arslan.py @@ -0,0 +1,21 @@ +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: + """ + This function returns the result of an operation based on the specified base and exponent values. + :param x: First base value + :param y: Second base value + :param a: First exponent value + :param b: Second exponent value + :param c: Divisor value + :return: (x**a + y**b)/c + """ + return (x ** a + y ** b) / c + + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "count"): + fn_w_counter.count = 0 + fn_w_counter.count += 1 + return fn_w_counter.count, {__name__.split('.')[-1]: fn_w_counter.count}