From 1aef47bbd6914a434e8cf7aff996e2f42c38a92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Mert=20Yi=C4=9Fit?= <161603309+MehmetMertYigit@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:20:10 +0300 Subject: [PATCH 1/4] Create functions_mehmet_mert_yigit.py --- Week04/functions_mehmet_mert_yigit.py | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Week04/functions_mehmet_mert_yigit.py diff --git a/Week04/functions_mehmet_mert_yigit.py b/Week04/functions_mehmet_mert_yigit.py new file mode 100644 index 00000000..2e1b8a63 --- /dev/null +++ b/Week04/functions_mehmet_mert_yigit.py @@ -0,0 +1,40 @@ +import inspect + + +custom_power = lambda x=0, e=1, /: x ** e + + +def custom_equation( + x: int, + y: int = 0, + /, + a: int = 1, + b: int = 1, + *, + c: int = 1 +) -> float: + """ + Calculate the result of the equation. + + :param x: First integer. + :param y: Second integer. + :param a: Exponent of x. + :param b: Exponent of y. + :param c: Divisor. + :return: Result of the equation. + :rtype: float + """ + return float((x ** a + y ** b) / c) + + +def fn_w_counter(): + if not hasattr(fn_w_counter, "counts"): + fn_w_counter.counts = {} + + caller = inspect.currentframe().f_back + caller_name = caller.f_code.co_name + + counts = fn_w_counter.counts + counts[caller_name] = counts.get(caller_name, 0) + 1 + + return sum(counts.values()), counts.copy() From 2e5fcdd6526552a8cb0766001954ed7f32a0e4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Mert=20Yi=C4=9Fit?= <161603309+MehmetMertYigit@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:24:50 +0300 Subject: [PATCH 2/4] Update functions_mehmet_mert_yigit.py --- Week04/functions_mehmet_mert_yigit.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Week04/functions_mehmet_mert_yigit.py b/Week04/functions_mehmet_mert_yigit.py index 2e1b8a63..23128b65 100644 --- a/Week04/functions_mehmet_mert_yigit.py +++ b/Week04/functions_mehmet_mert_yigit.py @@ -1,7 +1,7 @@ import inspect -custom_power = lambda x=0, e=1, /: x ** e +custom_power = lambda x=0, /, e=1: x ** e def custom_equation( @@ -21,13 +21,13 @@ def custom_equation( :param a: Exponent of x. :param b: Exponent of y. :param c: Divisor. - :return: Result of the equation. + :return: The calculated result. :rtype: float """ return float((x ** a + y ** b) / c) -def fn_w_counter(): +def fn_w_counter() -> tuple[int, dict[str, int]]: if not hasattr(fn_w_counter, "counts"): fn_w_counter.counts = {} From 2a365f58bcfb1d14263666337bc5e6ef0bb8fb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Mert=20Yi=C4=9Fit?= <161603309+MehmetMertYigit@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:30:46 +0300 Subject: [PATCH 3/4] Update functions_mehmet_mert_yigit.py --- Week04/functions_mehmet_mert_yigit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Week04/functions_mehmet_mert_yigit.py b/Week04/functions_mehmet_mert_yigit.py index 23128b65..df060818 100644 --- a/Week04/functions_mehmet_mert_yigit.py +++ b/Week04/functions_mehmet_mert_yigit.py @@ -5,7 +5,7 @@ def custom_equation( - x: int, + x: int = 0, y: int = 0, /, a: int = 1, @@ -27,12 +27,12 @@ def custom_equation( return float((x ** a + y ** b) / c) -def fn_w_counter() -> tuple[int, dict[str, int]]: +def fn_w_counter() -> (int, dict[str, int]): if not hasattr(fn_w_counter, "counts"): fn_w_counter.counts = {} - caller = inspect.currentframe().f_back - caller_name = caller.f_code.co_name + frame = inspect.currentframe().f_back + caller_name = frame.f_globals.get("__name__", "__main__") counts = fn_w_counter.counts counts[caller_name] = counts.get(caller_name, 0) + 1 From c2191b46a36726a7764c5d18fde5993ea52b8e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Mert=20Yi=C4=9Fit?= <161603309+MehmetMertYigit@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:36:38 +0300 Subject: [PATCH 4/4] Update functions_mehmet_mert_yigit.py --- Week04/functions_mehmet_mert_yigit.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Week04/functions_mehmet_mert_yigit.py b/Week04/functions_mehmet_mert_yigit.py index df060818..70e41a15 100644 --- a/Week04/functions_mehmet_mert_yigit.py +++ b/Week04/functions_mehmet_mert_yigit.py @@ -1,6 +1,3 @@ -import inspect - - custom_power = lambda x=0, /, e=1: x ** e @@ -31,8 +28,7 @@ def fn_w_counter() -> (int, dict[str, int]): if not hasattr(fn_w_counter, "counts"): fn_w_counter.counts = {} - frame = inspect.currentframe().f_back - caller_name = frame.f_globals.get("__name__", "__main__") + caller_name = fn_w_counter.__module__ counts = fn_w_counter.counts counts[caller_name] = counts.get(caller_name, 0) + 1