From 61bb08ef262739d7315bdb1d1cf90d7788456d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tar=C4=B1k=20Boz=C4=9Fan?= <156001177+protagonist9@users.noreply.github.com> Date: Mon, 5 Jan 2026 16:41:24 +0300 Subject: [PATCH] Add custom power and equation functions with call counter This file defines a custom power function and a custom equation function that performs calculations based on provided integer parameters. It also includes a function to count calls to it. --- Week04/functions_tarik_bozgan.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Week04/functions_tarik_bozgan.py diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py new file mode 100644 index 00000000..73256d91 --- /dev/null +++ b/Week04/functions_tarik_bozgan.py @@ -0,0 +1,32 @@ +# custom_power (lambda) +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: + """ + :param x: integer value + :param y: integer value + :param a: integer value + :param b: integer value + :param c: integer value + :return: result of equation + """ + if not all(isinstance(v, int) for v in (x, y, a, b, c)): + raise TypeError("All parameters must be int") + + return (x ** a + y ** b) / c + + +_call_count = 0 + +def fn_w_counter() -> (int, dict[str, int]): + global _call_count + _call_count += 1 + return _call_count, {__name__: _call_count}