From 4e08e0c1d2caa467349dbc52b6206c585b065061 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Wed, 22 Oct 2025 02:39:02 +0300 Subject: [PATCH 01/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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 = {} From bc37b5058163ffea9d9b622dbbb3fb10e9b2858a Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 21:07:43 +0300 Subject: [PATCH 14/15] Bug fixing --- Week04/decorators_tarik_bozgan.py | 41 +++++++++++++++---------------- Week04/functions_tarik_bozgan.py | 32 +++++++----------------- 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/Week04/decorators_tarik_bozgan.py b/Week04/decorators_tarik_bozgan.py index f92cb3fa..3d4dd207 100644 --- a/Week04/decorators_tarik_bozgan.py +++ b/Week04/decorators_tarik_bozgan.py @@ -1,24 +1,23 @@ -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) +import time, tracemalloc +from functools import wraps - wrapper.counter += 1 - wrapper.total_time += (end_time - start_time) - wrapper.total_mem += mem_usage - - return result +def performance(func): + performance.c = performance.c + 1 if hasattr(performance, "c") else 1 + performance.t = getattr(performance, "t", 0.0) + performance.m = getattr(performance, "m", 0) - wrapper.counter = 0 - wrapper.total_time = 0 - wrapper.total_mem = 0 + @wraps(func) + def wrapper(*a, **k): + performance.c += 1 + t0 = time.perf_counter() + tracemalloc.start() + r = func(*a, **k) + performance.t += time.perf_counter() - t0 + performance.m += tracemalloc.get_traced_memory()[1] + tracemalloc.stop() + return r + return wrapper - return wrapper \ No newline at end of file +performance.counter = 0 +performance.total_time = 0.0 +performance.total_mem = 0 \ No newline at end of file diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index 01e864c6..dfdc38c9 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -1,29 +1,15 @@ -import sys - custom_power = lambda x=0, /, e=1: x**e +"""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: - """ - 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 - """ +def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: + """(x**a + y**b) / c""" return (x**a + y**b) / c -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 = {} - - 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 - return fn_w_counter.count, fn_w_counter.callers \ No newline at end of file +def fn_w_counter() -> tuple[int, dict[str, int]]: + caller = __name__ if __name__ != "" else "lambda" + fn_w_counter.total = getattr(fn_w_counter, "total", 0) + 1 + fn_w_counter.callers = getattr(fn_w_counter, "callers", {}) + fn_w_counter.callers[caller] = fn_w_counter.callers.get(caller, 0) + 1 + return fn_w_counter.total, fn_w_counter.callers.copy() \ No newline at end of file From d1207061e63918ff817d4c8542f9b4ea997f6762 Mon Sep 17 00:00:00 2001 From: protagonist9 Date: Sat, 6 Dec 2025 21:11:30 +0300 Subject: [PATCH 15/15] Bug fixing again --- Week04/functions_tarik_bozgan.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Week04/functions_tarik_bozgan.py b/Week04/functions_tarik_bozgan.py index dfdc38c9..16fba91b 100644 --- a/Week04/functions_tarik_bozgan.py +++ b/Week04/functions_tarik_bozgan.py @@ -3,7 +3,15 @@ def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: - """(x**a + y**b) / c""" + """ + Calculates the result. + :param x: Base number 1 + :param y: Base number 2 + :param a: Exponent for x + :param b: Exponent for y + :param c: Divisor + :return: The calculated result as a float + """ return (x**a + y**b) / c