From dfd49e2a75702b010f4a146e1e4e60f180901838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Hakan=20Y=C4=B1ld=C4=B1r=C4=B1m?= Date: Tue, 31 Mar 2026 22:23:57 +0300 Subject: [PATCH 1/2] Add custom power and equation functions --- Week04/functions_ahmet_hakan_yildirim.py | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Week04/functions_ahmet_hakan_yildirim.py diff --git a/Week04/functions_ahmet_hakan_yildirim.py b/Week04/functions_ahmet_hakan_yildirim.py new file mode 100644 index 00000000..2cad1635 --- /dev/null +++ b/Week04/functions_ahmet_hakan_yildirim.py @@ -0,0 +1,42 @@ +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: positional-only + :param y: positional-only + :param a: positional or keyword + :param b: positional or keyword + :param c: keyword-only + :return: result as float + """ + + values = [x, y, a, b, c] + + for v in values: + if not isinstance(v, int): + raise TypeError("Arguments must be integers") + + numerator = (x ** a + y ** b) + result = numerator / c + + return float(result) + + +def fn_w_counter() -> tuple[int, dict[str, int]]: + if getattr(fn_w_counter, "count", None) is None: + fn_w_counter.count = 0 + + fn_w_counter.count += 1 + + module_name = __name__.split('.')[-1] + + return fn_w_counter.count, {module_name: fn_w_counter.count} From 217a639b9f96046059e394611dedcbccbc43ccc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Hakan=20Y=C4=B1ld=C4=B1r=C4=B1m?= Date: Tue, 31 Mar 2026 22:28:02 +0300 Subject: [PATCH 2/2] Add type hints to custom_equation and fn_w_counter --- Week04/functions_ahmet_hakan_yildirim.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Week04/functions_ahmet_hakan_yildirim.py b/Week04/functions_ahmet_hakan_yildirim.py index 2cad1635..42414d9e 100644 --- a/Week04/functions_ahmet_hakan_yildirim.py +++ b/Week04/functions_ahmet_hakan_yildirim.py @@ -1,3 +1,5 @@ +from typing import Tuple, Dict + custom_power = lambda x=0, /, e=1: (x ** e) @@ -31,7 +33,7 @@ def custom_equation( return float(result) -def fn_w_counter() -> tuple[int, dict[str, int]]: +def fn_w_counter() -> Tuple[int, Dict[str, int]]: if getattr(fn_w_counter, "count", None) is None: fn_w_counter.count = 0