diff --git a/Week03/functions_burak_talha_memis.py b/Week03/functions_burak_talha_memis.py index 775fb145..e0e9da95 100644 --- a/Week03/functions_burak_talha_memis.py +++ b/Week03/functions_burak_talha_memis.py @@ -1,6 +1,6 @@ custom_power = lambda x = 0,/,e = 1: x**e -def custom_equation(x = 0,y = 0,/,a = 1,b = 1, * ,c = 1)->float: +def custom_equation(x:int = 0, y:int = 0, /, a:int = 1, b:int = 1, *, c:int = 1) -> float: """ This function :param x:The first number, default is 0 @@ -18,18 +18,16 @@ def custom_equation(x = 0,y = 0,/,a = 1,b = 1, * ,c = 1)->float: """ return (x**a + y**b) / c -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 - - if not hasattr(fn_w_counter, 'callers'): - fn_w_counter.callers = {f"{__name__}": 1} +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "call_count"): + fn_w_counter.call_count = 0 + fn_w_counter._dict = {} + caller_name = __name__ + fn_w_counter.call_count += 1 + if caller_name in fn_w_counter._dict: + fn_w_counter._dict[caller_name] += 1 else: - if __name__ in fn_w_counter.callers: - fn_w_counter.callers[__name__] += 1 - else: - fn_w_counter.callers[__name__] = 1 + fn_w_counter._dict[caller_name] = 1 + return fn_w_counter.call_count, fn_w_counter._dict