From 1972769e93da7c57b50128e22b824fc92bbfea20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Recep=20G=C3=B6ktu=C4=9F=20Avc=C4=B1?= Date: Wed, 18 Nov 2026 21:01:54 +0300 Subject: [PATCH] Add custom_equation and fn_w_counter functions Implement custom polynomial equation and counter function. --- Week04/functions_recep_goktug_avci.py | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Week04/functions_recep_goktug_avci.py diff --git a/Week04/functions_recep_goktug_avci.py b/Week04/functions_recep_goktug_avci.py new file mode 100644 index 00000000..a7c9dcff --- /dev/null +++ b/Week04/functions_recep_goktug_avci.py @@ -0,0 +1,29 @@ +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: + """Calculate custom polynomial equation result. + + Calculates :math:`\\frac{x^a + y^b}{c}`. + + :param x: Positional-only x value, defaults to 0 + :type x: int, optional + :param y: Positional-only y value, defaults to 0 + :type y: int, optional + :param a: Positional-or-keyword exponent for x, defaults to 1 + :type a: int, optional + :param b: Positional-or-keyword exponent for y, defaults to 1 + :type b: int, optional + :param c: Keyword-only denominator, defaults to 1 + :type c: int, optional + :return: Result of (x**a + y**b) / c + :rtype: float + """ + return (x**a + y**b) / c + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "counter"): + fn_w_counter.counter = 0 + fn_w_counter.counter += 1 + return (fn_w_counter.counter, {fn_w_counter.__module__: fn_w_counter.counter}) +if __name__ == "__main__": + print(fn_w_counter())