From 4e08e0c1d2caa467349dbc52b6206c585b065061 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Wed, 22 Oct 2025 02:39:02 +0300 Subject: [PATCH 01/13] Created pyramid_first_last.py --- Week03/pyramid_first_last.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Week03/pyramid_first_last.py diff --git a/Week03/pyramid_first_last.py b/Week03/pyramid_first_last.py new file mode 100644 index 00000000..fa762647 --- /dev/null +++ b/Week03/pyramid_first_last.py @@ -0,0 +1,7 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + while(number_of_blocks >= 0): + height += 1 + number_of_blocks -= height + return height - 1 + From 043bf57b098602f279d0cedd12bc1267a65a3703 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Mon, 27 Oct 2025 18:48:32 +0300 Subject: [PATCH 02/13] Created pyramid_tarik_bozgan.py --- Week03/{pyramid_first_last.py => pyramid_tarik_bozgan.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Week03/{pyramid_first_last.py => pyramid_tarik_bozgan.py} (100%) diff --git a/Week03/pyramid_first_last.py b/Week03/pyramid_tarik_bozgan.py similarity index 100% rename from Week03/pyramid_first_last.py rename to Week03/pyramid_tarik_bozgan.py From 06cd05ccdfbabdc7d3318c08dcca24a31844e834 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:28:01 +0300 Subject: [PATCH 03/13] Created functions_tarik_bozgan.py --- Week04/functions_tarik_bozgan.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Week04/functions_tarik_bozgan.py diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py new file mode 100644 index 00000000..03fd3687 --- /dev/null +++ b/Week04/functions_tarik_bozgan.py @@ -0,0 +1,12 @@ +def custom_power(x, e=1): + return x ** e + +def custom_equation(x, y, a=1, b=1, *, c=1): + return (x ** a + y ** b) / c + +call_counts = {} + +def fn_w_counter(): + caller_name = __import__('inspect').currentframe().f_back.f_code.co_name + call_counts[caller_name] = call_counts.get(caller_name, 0) + 1 + return (call_counts[caller_name], {k: v for k, v in call_counts.items()}) \ No newline at end of file From bb4274694665240481dd1ba25a30b6090ce2741d Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:31:48 +0300 Subject: [PATCH 04/13] Created decorators_tarik_bozgan.py --- Week04/decorators_tarik_bozgan.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Week04/decorators_tarik_bozgan.py diff --git a/Week04/decorators_tarik_bozgan.py b/Week04/decorators_tarik_bozgan.py new file mode 100644 index 00000000..b26f71a9 --- /dev/null +++ b/Week04/decorators_tarik_bozgan.py @@ -0,0 +1,26 @@ +def custom_power(x, e=1): + return x ** e + +def custom_equation(x, y, a=1, b=1, *, c=1): + return (x ** a + y ** b) / c + +_calls = {} + +def fn_w_counter(): + caller = __import__('inspect').currentframe().f_back.f_code.co_name + _calls[caller] = _calls.get(caller, 0) + 1 + return (_calls[caller], dict(_calls)) + +def performance(f): + def w(*a, **k): + import time, tracemalloc + tracemalloc.start() + t = time.time() + r = f(*a, **k) + w.total_time += time.time() - t + w.total_mem += tracemalloc.get_traced_memory()[0] + tracemalloc.stop() + w.counter += 1 + return r + w.counter = w.total_time = w.total_mem = 0 + return w \ No newline at end of file From 98a608bae20630959d162cbd7e5056a820048d09 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:35:27 +0300 Subject: [PATCH 05/13] Bugs fixed --- Week04/decorators_tarik_bozgan.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Week04/decorators_tarik_bozgan.py b/Week04/decorators_tarik_bozgan.py index b26f71a9..35e9e4b1 100644 --- a/Week04/decorators_tarik_bozgan.py +++ b/Week04/decorators_tarik_bozgan.py @@ -1,5 +1,4 @@ -def custom_power(x, e=1): - return x ** e +custom_power = lambda x, e=1: x ** e def custom_equation(x, y, a=1, b=1, *, c=1): return (x ** a + y ** b) / c From 662d77f63b9bb25b034705e7b4d86bb4595007e3 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:38:22 +0300 Subject: [PATCH 06/13] Bugs fixed --- Week04/decorators_tarik_bozgan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/decorators_tarik_bozgan.py b/Week04/decorators_tarik_bozgan.py index 35e9e4b1..422659c1 100644 --- a/Week04/decorators_tarik_bozgan.py +++ b/Week04/decorators_tarik_bozgan.py @@ -8,7 +8,7 @@ def custom_equation(x, y, a=1, b=1, *, c=1): def fn_w_counter(): caller = __import__('inspect').currentframe().f_back.f_code.co_name _calls[caller] = _calls.get(caller, 0) + 1 - return (_calls[caller], dict(_calls)) + return _calls[caller], dict(_calls) def performance(f): def w(*a, **k): From 3dfc44683bbb4d7f0a7d529d445bc1b43419700f Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:42:32 +0300 Subject: [PATCH 07/13] Bugs got fixed --- Week04/decorators_tarik_bozgan.py | 12 ------------ Week04/functions_tarik_bozgan.py | 11 +++++------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Week04/decorators_tarik_bozgan.py b/Week04/decorators_tarik_bozgan.py index 422659c1..c979a806 100644 --- a/Week04/decorators_tarik_bozgan.py +++ b/Week04/decorators_tarik_bozgan.py @@ -1,15 +1,3 @@ -custom_power = lambda x, e=1: x ** e - -def custom_equation(x, y, a=1, b=1, *, c=1): - return (x ** a + y ** b) / c - -_calls = {} - -def fn_w_counter(): - caller = __import__('inspect').currentframe().f_back.f_code.co_name - _calls[caller] = _calls.get(caller, 0) + 1 - return _calls[caller], dict(_calls) - def performance(f): def w(*a, **k): import time, tracemalloc diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index 03fd3687..2865ed76 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -1,12 +1,11 @@ -def custom_power(x, e=1): - return x ** e +custom_power = lambda x, e=1: x ** e def custom_equation(x, y, a=1, b=1, *, c=1): return (x ** a + y ** b) / c -call_counts = {} +_calls = {} def fn_w_counter(): - caller_name = __import__('inspect').currentframe().f_back.f_code.co_name - call_counts[caller_name] = call_counts.get(caller_name, 0) + 1 - return (call_counts[caller_name], {k: v for k, v in call_counts.items()}) \ No newline at end of file + caller = __import__('inspect').currentframe().f_back.f_code.co_name + _calls[caller] = _calls.get(caller, 0) + 1 + return _calls[caller], dict(_calls) \ No newline at end of file From f402ef050f6f2f41fa30adebe96d114e5cc45983 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:45:46 +0300 Subject: [PATCH 08/13] Bug fix trial 4 --- Week04/functions_tarik_bozgan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index 2865ed76..1efc28dd 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -1,6 +1,6 @@ -custom_power = lambda x, e=1: x ** e +custom_power = lambda x, /, e=1: x ** e -def custom_equation(x, y, a=1, b=1, *, c=1): +def custom_equation(x, y, /, a=1, b=1, *, c=1): return (x ** a + y ** b) / c _calls = {} From e83bb03015898839fefd6752c24cd1e56dcd5f1f Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:49:00 +0300 Subject: [PATCH 09/13] Bug fix trial 5 --- Week04/functions_tarik_bozgan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index 1efc28dd..8a26e016 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -1,6 +1,6 @@ -custom_power = lambda x, /, e=1: x ** e +custom_power = lambda x=0, /, e=1: x ** e -def custom_equation(x, y, /, a=1, b=1, *, c=1): +def custom_equation(x=0, y=0, /, a=1, b=1, *, c=1): return (x ** a + y ** b) / c _calls = {} From c6142fd4e16c3f0be5d848e4083e5d82db881d1e Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:51:44 +0300 Subject: [PATCH 10/13] Bug fixing 6th trial --- Week04/functions_tarik_bozgan.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index 8a26e016..cbbd6101 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -1,6 +1,16 @@ custom_power = lambda x=0, /, e=1: x ** e -def custom_equation(x=0, y=0, /, a=1, b=1, *, c=1): +def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: + """ + Returns (x**a + y**b) / c + + :param x: First value + :param y: Second value + :param a: Exponent for x + :param b: Exponent for y + :param c: Divisor + :return: Result of (x**a + y**b) / c + """ return (x ** a + y ** b) / c _calls = {} From 180752824d6805b64ca8410efe37208127951510 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 20:54:23 +0300 Subject: [PATCH 11/13] Bug fix 7th trial --- Week04/functions_tarik_bozgan.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index cbbd6101..fa46b2c0 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -2,20 +2,21 @@ def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: """ - Returns (x**a + y**b) / c + Calculate (x**a + y**b) / c - :param x: First value - :param y: Second value + :param x: First base value + :param y: Second base value :param a: Exponent for x :param b: Exponent for y :param c: Divisor - :return: Result of (x**a + y**b) / c + :return: The result of (x**a + y**b) / c + :rtype: float """ return (x ** a + y ** b) / c _calls = {} -def fn_w_counter(): +def fn_w_counter() -> tuple[int, dict[str, int]]: caller = __import__('inspect').currentframe().f_back.f_code.co_name _calls[caller] = _calls.get(caller, 0) + 1 return _calls[caller], dict(_calls) \ No newline at end of file From 4c5a411e77cb0622bdfa355a11a082c069f0c8e6 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 21:02:03 +0300 Subject: [PATCH 12/13] Bug fixing 9th trial --- Week04/decorators_tarik_bozgan.py | 37 ++++++++++++++++++++----------- Week04/functions_tarik_bozgan.py | 37 ++++++++++++++++++------------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/Week04/decorators_tarik_bozgan.py b/Week04/decorators_tarik_bozgan.py index c979a806..f92cb3fa 100644 --- a/Week04/decorators_tarik_bozgan.py +++ b/Week04/decorators_tarik_bozgan.py @@ -1,13 +1,24 @@ -def performance(f): - def w(*a, **k): - import time, tracemalloc - tracemalloc.start() - t = time.time() - r = f(*a, **k) - w.total_time += time.time() - t - w.total_mem += tracemalloc.get_traced_memory()[0] - tracemalloc.stop() - w.counter += 1 - return r - w.counter = w.total_time = w.total_mem = 0 - return w \ No newline at end of file +import time +import sys +import functools +def performance(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + start_time = time.perf_counter() + + result = func(*args, **kwargs) + + end_time = time.perf_counter() + mem_usage = sys.getsizeof(result) + + wrapper.counter += 1 + wrapper.total_time += (end_time - start_time) + wrapper.total_mem += mem_usage + + return result + + wrapper.counter = 0 + wrapper.total_time = 0 + wrapper.total_mem = 0 + + return wrapper \ No newline at end of file diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index fa46b2c0..162fb33d 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -1,22 +1,29 @@ -custom_power = lambda x=0, /, e=1: x ** e +import sys + +custom_power = lambda x, /, e=1: x**e def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: """ - Calculate (x**a + y**b) / c - - :param x: First base value - :param y: Second base value - :param a: Exponent for x - :param b: Exponent for y - :param c: Divisor - :return: The result of (x**a + y**b) / c + Belirtilen formüle göre kayan noktalı bir sayı döndürür. + + :param x: Konumsal-tek parametre (Varsayılan 0). + :param y: Konumsal-tek parametre (Varsayılan 0). + :param a: Konumsal-veya-anahtar kelime parametresi (Varsayılan 1). + :param b: Konumsal-veya-anahtar kelime parametresi (Varsayılan 1). + :param c: Anahtar kelime-tek parametre (Varsayılan 1). + :returns: (x**a + y**b) / c formülünün sonucunu döndürür. :rtype: float """ - return (x ** a + y ** b) / c + return (x**a + y**b) / c -_calls = {} +def fn_w_counter() -> tuple: + if not hasattr(fn_w_counter, 'count'): + fn_w_counter.count = 0 + fn_w_counter.callers = {} + + caller_name = sys._getframe(1).f_globals['__name__'] + + fn_w_counter.count += 1 + fn_w_counter.callers[caller_name] = fn_w_counter.callers.get(caller_name, 0) + 1 -def fn_w_counter() -> tuple[int, dict[str, int]]: - caller = __import__('inspect').currentframe().f_back.f_code.co_name - _calls[caller] = _calls.get(caller, 0) + 1 - return _calls[caller], dict(_calls) \ No newline at end of file + return fn_w_counter.count, fn_w_counter.callers \ No newline at end of file From e5707873d0c57b10fc89492aaf213f036215bab3 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 21:04:09 +0300 Subject: [PATCH 13/13] 10th commit to fix bugs --- Week04/functions_tarik_bozgan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index 162fb33d..01e864c6 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -1,6 +1,6 @@ import sys -custom_power = lambda x, /, 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: """ @@ -16,7 +16,7 @@ def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int """ return (x**a + y**b) / c -def fn_w_counter() -> tuple: +def fn_w_counter() -> tuple[int, dict[str, int]]: if not hasattr(fn_w_counter, 'count'): fn_w_counter.count = 0 fn_w_counter.callers = {}