From 86c0f4f7bda20e34268b616bc3db23b470e0d3bc Mon Sep 17 00:00:00 2001 From: meldag006 Date: Tue, 27 Oct 2026 15:40:21 +0300 Subject: [PATCH 1/2] Add custom_power and custom_equation functions Implement custom power and equation functions with a call counter. --- Week04/functions_melda_gungor.py | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Week04/functions_melda_gungor.py diff --git a/Week04/functions_melda_gungor.py b/Week04/functions_melda_gungor.py new file mode 100644 index 00000000..da4ace15 --- /dev/null +++ b/Week04/functions_melda_gungor.py @@ -0,0 +1,38 @@ +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: + """ + Calculates the custom equation. + :param x: first base + :type x: int + :param y: second base + :type y: int + :param a: exponent for x + :type a: int + :param b: exponent for y + :type b: int + :param c: divisor + :type c: int + :return: the result of (x**a + y**b) / c + :rtype: float """ + + return float((x**a + y**b) / c) + + +def fn_w_counter() -> tuple[int , dict[str,int]]: + if not hasattr(fn_w_counter,"total_count"): + fn_w_counter.total_count = 0 + fn_w_counter.call_records = {} + + caller = __name__ + fn_w_counter.total_count += 1 + + if caller not in fn_w_counter.call_records: + fn_w_counter.call_records[caller] = 1 + else: + fn_w_counter.call_records[caller] += 1 + + return fn_w_counter.total_count, fn_w_counter.call_records + + + From 523c44d9168c52e53bafbf4419f0f7d11f67917b Mon Sep 17 00:00:00 2001 From: meldag006 Date: Tue, 27 Oct 2026 15:45:55 +0300 Subject: [PATCH 2/2] Refactor custom_equation and fn_w_counter signatures Updated function signatures for better clarity and consistency. --- Week04/functions_melda_gungor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Week04/functions_melda_gungor.py b/Week04/functions_melda_gungor.py index da4ace15..987e46ab 100644 --- a/Week04/functions_melda_gungor.py +++ b/Week04/functions_melda_gungor.py @@ -1,6 +1,6 @@ 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: """ Calculates the custom equation. :param x: first base @@ -14,12 +14,13 @@ def custom_equation(x: int = 0, y: int = 0, /, a: int =1 ,b: int =1,*,c: int=1) :param c: divisor :type c: int :return: the result of (x**a + y**b) / c - :rtype: float """ + :rtype: float + """ 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,"total_count"): fn_w_counter.total_count = 0 fn_w_counter.call_records = {}