From 11f818c334e2c63d508cc01d37f7877510f4b86c Mon Sep 17 00:00:00 2001 From: Extocraftor <51536864+Extocraftor@users.noreply.github.com> Date: Thu, 17 Oct 2024 20:33:40 +0300 Subject: [PATCH 1/5] Create functions_mert_durgun.py --- Week04/functions_mert_durgun.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Week04/functions_mert_durgun.py diff --git a/Week04/functions_mert_durgun.py b/Week04/functions_mert_durgun.py new file mode 100644 index 00000000..91f97844 --- /dev/null +++ b/Week04/functions_mert_durgun.py @@ -0,0 +1,10 @@ +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: + return (a * x + b * y) / c + +counter = 0 +def fn_w_counter() -> (int, dict[str, int]): + global counter + counter += 1 + return counter, {"functions_1": counter} From 2b0f40c8e9634229dfbfc5bc1ba989e2c4c7cfc2 Mon Sep 17 00:00:00 2001 From: Extocraftor <51536864+Extocraftor@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:51:26 +0300 Subject: [PATCH 2/5] Update functions_mert_durgun.py --- Week04/functions_mert_durgun.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Week04/functions_mert_durgun.py b/Week04/functions_mert_durgun.py index 91f97844..62305f1c 100644 --- a/Week04/functions_mert_durgun.py +++ b/Week04/functions_mert_durgun.py @@ -5,6 +5,5 @@ def custom_equation(x: int = 0, y: int = 0, a: int = 1, b: int = 1, *, c: int = counter = 0 def fn_w_counter() -> (int, dict[str, int]): - global counter counter += 1 return counter, {"functions_1": counter} From 01e676172b3ed08505c8daff535f656a85ce4326 Mon Sep 17 00:00:00 2001 From: Extocraftor <51536864+Extocraftor@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:52:55 +0300 Subject: [PATCH 3/5] Update functions_mert_durgun.py --- Week04/functions_mert_durgun.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Week04/functions_mert_durgun.py b/Week04/functions_mert_durgun.py index 62305f1c..3e40cd7d 100644 --- a/Week04/functions_mert_durgun.py +++ b/Week04/functions_mert_durgun.py @@ -1,9 +1,16 @@ -custom_power = lambda x=0, e=1: x ** e +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: - return (a * x + b * y) / c +def custom_equation(x: int = 0, y: int = 0,/, a: int = 1, b: int = 1, *, c: int=1) -> float: + return (x**a + y**b) / c -counter = 0 -def fn_w_counter() -> (int, dict[str, int]): - counter += 1 - return counter, {"functions_1": counter} + +def fn_w_counter() -> (int, dict[str,int]): + + if not hasattr(fn_w_counter, "counter"): + fn_w_counter.counter = 0 + + fn_w_counter.counter += 1 + module_name = __name__ + call_counter_dict = {module_name: fn_w_counter.counter} + + return fn_w_counter.counter, call_counter_dict From 0e6a9d24d583867078872b6a7847d009f0ea8faa Mon Sep 17 00:00:00 2001 From: Extocraftor <51536864+Extocraftor@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:56:33 +0300 Subject: [PATCH 4/5] Update functions_mert_durgun.py --- Week04/functions_mert_durgun.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Week04/functions_mert_durgun.py b/Week04/functions_mert_durgun.py index 3e40cd7d..e8f8a6b0 100644 --- a/Week04/functions_mert_durgun.py +++ b/Week04/functions_mert_durgun.py @@ -1,16 +1,19 @@ -custom_power = lambda x=0, /, e=1 : x**e +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: return (x**a + y**b) / c -def fn_w_counter() -> (int, dict[str,int]): + +def fn_w_counter() -> (int, dict[str, int]): if not hasattr(fn_w_counter, "counter"): fn_w_counter.counter = 0 - + fn_w_counter.dict = {} + caller_name = __name__ fn_w_counter.counter += 1 - module_name = __name__ - call_counter_dict = {module_name: fn_w_counter.counter} - - return fn_w_counter.counter, call_counter_dict + if caller_name in fn_w_counter.dict: + fn_w_counter.dict[caller_name] += 1 + else: + fn_w_counter.dict[caller_name] = 1 + return fn_w_counter.counter, fn_w_counter.dict From 1df15242a5dfb5fe01feb6851767f66834273e28 Mon Sep 17 00:00:00 2001 From: Extocraftor <51536864+Extocraftor@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:58:43 +0300 Subject: [PATCH 5/5] Update functions_mert_durgun.py --- Week04/functions_mert_durgun.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Week04/functions_mert_durgun.py b/Week04/functions_mert_durgun.py index e8f8a6b0..0b4313a9 100644 --- a/Week04/functions_mert_durgun.py +++ b/Week04/functions_mert_durgun.py @@ -1,6 +1,15 @@ 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: The positional-only integer base for the first term, default is 0 + :param y: The positional-only integer base for the second term, default is 0 + :param a: The positional-or-keyword integer exponent for the first term, default is 1 + :param b: The positional-or-keyword integer exponent for the second term, default is 1 + :param c: The keyword-only integer divisor, default is 1 + :return: The result of the calculation as a float + :rtype: float + """ return (x**a + y**b) / c