From aba6c4d613632f9436fccdf4c1ed2218afb63837 Mon Sep 17 00:00:00 2001 From: SlainST Date: Wed, 8 Apr 2026 07:41:33 +0300 Subject: [PATCH] Add custom power and equation functions with counter --- Week04/functions_serhat_tufan.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Week04/functions_serhat_tufan.py diff --git a/Week04/functions_serhat_tufan.py b/Week04/functions_serhat_tufan.py new file mode 100644 index 00000000..d39e73c6 --- /dev/null +++ b/Week04/functions_serhat_tufan.py @@ -0,0 +1,25 @@ +def custom_power(x=0, /, e=1): + return x ** e + + + + + +def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: + + + for param_name, value in [('x', x), ('y', y), ('a', a), ('b', b), ('c', c)]: + if not isinstance(value, int): + raise TypeError(f"{param_name} must be an integer") + + return float((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__: fn_w_counter.count}