From 378fe500cf69c095d8438e1685b06cfccc3db764 Mon Sep 17 00:00:00 2001 From: SelinKrg06 Date: Mon, 23 Mar 2026 23:42:19 +0300 Subject: [PATCH 1/3] Create functions_ayseselin_kargi.py --- Week04/functions_ayseselin_kargi.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Week04/functions_ayseselin_kargi.py diff --git a/Week04/functions_ayseselin_kargi.py b/Week04/functions_ayseselin_kargi.py new file mode 100644 index 00000000..f9014abd --- /dev/null +++ b/Week04/functions_ayseselin_kargi.py @@ -0,0 +1,27 @@ +import sys + +custom_power = lambda x=0, /, e=1: x ** e + +def custom_equation(x: float = 0, y: float = 0, /, a: float = 1, b: float = 1, *, c: float = 1) -> float: + """ + Computes a custom equation. + + :param x: positional-only, default 0 + :param y: positional-only, default 0 + :param a: positional or keyword, default 1 + :param b: positional or keyword, default 1 + :param c: keyword-only, default 1 + :return: result of (x**a + y**b) / c + """ + return (x ** a + y ** b) / c + +def fn_w_counter(): + if not hasattr(fn_w_counter, "count"): + fn_w_counter.count = 0 + fn_w_counter.callers = {} + + fn_w_counter.count += 1 + caller = sys._getframe(1).f_globals.get('__name__', 'unknown') + fn_w_counter.callers[caller] = fn_w_counter.callers.get(caller, 0) + 1 + + return fn_w_counter.count, fn_w_counter.callers From 00ac1b7fef533f4887be6191f8fa5ab147edf780 Mon Sep 17 00:00:00 2001 From: SelinKrg06 Date: Mon, 23 Mar 2026 23:51:04 +0300 Subject: [PATCH 2/3] Update functions_ayseselin_kargi.py --- Week04/functions_ayseselin_kargi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Week04/functions_ayseselin_kargi.py b/Week04/functions_ayseselin_kargi.py index f9014abd..a1ad19ab 100644 --- a/Week04/functions_ayseselin_kargi.py +++ b/Week04/functions_ayseselin_kargi.py @@ -2,7 +2,7 @@ custom_power = lambda x=0, /, e=1: x ** e -def custom_equation(x: float = 0, y: float = 0, /, a: float = 1, b: float = 1, *, c: float = 1) -> float: +def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: """ Computes a custom equation. @@ -13,9 +13,9 @@ def custom_equation(x: float = 0, y: float = 0, /, a: float = 1, b: float = 1, * :param c: keyword-only, default 1 :return: result of (x**a + y**b) / c """ - return (x ** a + y ** b) / c + return float((x ** a + y ** b) / c) -def fn_w_counter(): +def fn_w_counter() -> (int, dict[str, int]): if not hasattr(fn_w_counter, "count"): fn_w_counter.count = 0 fn_w_counter.callers = {} From 9a7b052a7b2a40551d9beb453d1b060a46dd3017 Mon Sep 17 00:00:00 2001 From: SelinKrg06 Date: Tue, 24 Mar 2026 00:01:33 +0300 Subject: [PATCH 3/3] Update functions_ayseselin_kargi.py --- Week04/functions_ayseselin_kargi.py | 36 +++++++++++++++++------------ 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Week04/functions_ayseselin_kargi.py b/Week04/functions_ayseselin_kargi.py index a1ad19ab..be511731 100644 --- a/Week04/functions_ayseselin_kargi.py +++ b/Week04/functions_ayseselin_kargi.py @@ -1,27 +1,33 @@ -import sys - 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: + +def custom_equation(x: int = 0, y: int = 0, /, + a: int = 1, b: int = 1, *, + c: int = 1) -> float: """ Computes a custom equation. - :param x: positional-only, default 0 - :param y: positional-only, default 0 - :param a: positional or keyword, default 1 - :param b: positional or keyword, default 1 - :param c: keyword-only, default 1 - :return: result of (x**a + y**b) / c + :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 """ + + for val in (x, y, a, b, c): + if not isinstance(val, int): + raise TypeError("Arguments must be integers") + 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.callers = {} - + fn_w_counter.count += 1 - caller = sys._getframe(1).f_globals.get('__name__', 'unknown') - fn_w_counter.callers[caller] = fn_w_counter.callers.get(caller, 0) + 1 - - return fn_w_counter.count, fn_w_counter.callers + + module_name = __name__.split('.')[-1] + + return fn_w_counter.count, {module_name: fn_w_counter.count}