From 96930f5f730ed6a2fc96fbf5c8c6a9a289cf34de Mon Sep 17 00:00:00 2001 From: Esra Kaya <112573124+esrakaya64@users.noreply.github.com> Date: Wed, 23 Oct 2024 22:12:29 +0300 Subject: [PATCH 1/5] Create functions_esra_kaya.py --- Week04/functions_esra_kaya.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Week04/functions_esra_kaya.py diff --git a/Week04/functions_esra_kaya.py b/Week04/functions_esra_kaya.py new file mode 100644 index 00000000..65db99c1 --- /dev/null +++ b/Week04/functions_esra_kaya.py @@ -0,0 +1,28 @@ +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: + """ + Calculate the result of the equation (x**a + y**b) / c. + + :param x: Positional-only integer with default value 0 + :param y: Positional-only integer with default value 0 + :param a: Positional-or-keyword integer with default value 1 + :param b: Positional-or-keyword integer with default value 1 + :param c: Keyword-only integer with default value 1 + :return: A float that is the result of the equation (x**a + y**b) / c + """ + return (x**a + y**b) / c + +def fn_w_counter(): + fn_w_counter.counter += 1 + if not hasattr(fn_w_counter, 'call_dict'): + fn_w_counter.call_dict = {} + + caller = '__main__' + if caller in fn_w_counter.call_dict: + fn_w_counter.call_dict[caller] += 1 + else: + fn_w_counter.call_dict[caller] = 1 + + return fn_w_counter.counter, fn_w_counter.call_dict + From 1f75c1c859b41399bd52e48f4d7582311519a179 Mon Sep 17 00:00:00 2001 From: Esra Kaya <112573124+esrakaya64@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:33:21 +0300 Subject: [PATCH 2/5] Update functions_esra_kaya.py --- Week04/functions_esra_kaya.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/functions_esra_kaya.py b/Week04/functions_esra_kaya.py index 65db99c1..024ed50d 100644 --- a/Week04/functions_esra_kaya.py +++ b/Week04/functions_esra_kaya.py @@ -1,4 +1,4 @@ -def custom_power(x=0, /, e=1): return 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: """ From 0bc779d9dd590b81c858c782bbca8900b00ac565 Mon Sep 17 00:00:00 2001 From: Esra Kaya <112573124+esrakaya64@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:33:37 +0300 Subject: [PATCH 3/5] Update2 functions_esra_kaya.py --- Week04/functions_esra_kaya.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/functions_esra_kaya.py b/Week04/functions_esra_kaya.py index 024ed50d..b5fbf084 100644 --- a/Week04/functions_esra_kaya.py +++ b/Week04/functions_esra_kaya.py @@ -1,4 +1,4 @@ -custom_power = lambda x=0, /, e=1: x ** e +def 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: """ From 4af23b80667ce974a2bf3a33fa0ee425a462be2d Mon Sep 17 00:00:00 2001 From: Esra Kaya <112573124+esrakaya64@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:34:15 +0300 Subject: [PATCH 4/5] Update3 functions_esra_kaya.py sorry about "def" --- Week04/functions_esra_kaya.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/functions_esra_kaya.py b/Week04/functions_esra_kaya.py index b5fbf084..024ed50d 100644 --- a/Week04/functions_esra_kaya.py +++ b/Week04/functions_esra_kaya.py @@ -1,4 +1,4 @@ -def 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: """ From 80130a88b3d8d54cf952aa1fc2599e948fc78150 Mon Sep 17 00:00:00 2001 From: Esra Kaya <112573124+esrakaya64@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:24:33 +0300 Subject: [PATCH 5/5] Update functions_esra_kaya.py --- Week04/functions_esra_kaya.py | 50 +++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/Week04/functions_esra_kaya.py b/Week04/functions_esra_kaya.py index 024ed50d..537bccf5 100644 --- a/Week04/functions_esra_kaya.py +++ b/Week04/functions_esra_kaya.py @@ -1,28 +1,38 @@ -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: """ - Calculate the result of the equation (x**a + y**b) / c. - - :param x: Positional-only integer with default value 0 - :param y: Positional-only integer with default value 0 - :param a: Positional-or-keyword integer with default value 1 - :param b: Positional-or-keyword integer with default value 1 - :param c: Keyword-only integer with default value 1 - :return: A float that is the result of the equation (x**a + y**b) / c + This function calculates a custom equation that. + + :param x: Positional-only parameter, default value is 0. + :param y: Positional-only parameter, default value is 0. + :param a: Exponent for `x`, default value is 1. + :param b: Exponent for `y`, default value is 1. + :param c: Divisor of the equation, default value is 1. + + :type x: int + :type y: int + :type a: int + :type b: int + :type c: int + + :return: The result of the custom equation ((x^a)+(y^b))/c. + :rtype: float """ return (x**a + y**b) / c -def fn_w_counter(): - fn_w_counter.counter += 1 - if not hasattr(fn_w_counter, 'call_dict'): - fn_w_counter.call_dict = {} - caller = '__main__' - if caller in fn_w_counter.call_dict: - fn_w_counter.call_dict[caller] += 1 - else: - fn_w_counter.call_dict[caller] = 1 +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "call_counter"): + fn_w_counter.call_counter = 0 + fn_w_counter.caller_counts = {} - return fn_w_counter.counter, fn_w_counter.call_dict + caller = __name__ + fn_w_counter.call_counter += 1 + + if caller not in fn_w_counter.caller_counts: + fn_w_counter.caller_counts[caller] = 1 + else: + fn_w_counter.caller_counts[caller] += 1 + return fn_w_counter.call_counter, fn_w_counter.caller_counts