From 4dc52cc1ab3681472323e7128d44528888301f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:43:12 +0300 Subject: [PATCH 1/9] HW02 --- Week02/types_ozgun_kasapoglu.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Week02/types_ozgun_kasapoglu.py diff --git a/Week02/types_ozgun_kasapoglu.py b/Week02/types_ozgun_kasapoglu.py new file mode 100644 index 00000000..bb8de785 --- /dev/null +++ b/Week02/types_ozgun_kasapoglu.py @@ -0,0 +1,4 @@ +my_int = 230 +my_float = 315.0 +my_bool = True +my_complex = 12j From 176094e02eea4f2582b5512977a747ca083f1fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:47:11 +0300 Subject: [PATCH 2/9] HW03_pyramid --- Week03/pyramid_ozgun_kasapoglu.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Week03/pyramid_ozgun_kasapoglu.py diff --git a/Week03/pyramid_ozgun_kasapoglu.py b/Week03/pyramid_ozgun_kasapoglu.py new file mode 100644 index 00000000..4090bf43 --- /dev/null +++ b/Week03/pyramid_ozgun_kasapoglu.py @@ -0,0 +1,10 @@ +def calculate_pyramid_height(blocks): + height = 0 + blocks_needed = 1 + + while blocks >= blocks_needed: + blocks -= blocks_needed + height += 1 + blocks_needed += 1 + + return height From 8312c807f532c4c950bbae9536879003f7741cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:48:21 +0300 Subject: [PATCH 3/9] HW03_sequences --- Week03/sequences_ozgun_kasapoglu.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Week03/sequences_ozgun_kasapoglu.py diff --git a/Week03/sequences_ozgun_kasapoglu.py b/Week03/sequences_ozgun_kasapoglu.py new file mode 100644 index 00000000..bf2d99d0 --- /dev/null +++ b/Week03/sequences_ozgun_kasapoglu.py @@ -0,0 +1,19 @@ +def remove_duplicates(my_list): + return list(dict.fromkeys(my_list)) + + +def list_counts(my_list): + counts = {} + for item in my_list: + if item in counts: + counts[item] += 1 + else: + counts[item] = 1 + return counts + + +def reverse_dict(my_dict): + reversed_results = {} + for key, value in my_dict.items(): + reversed_results[value] = key + return reversed_results From 6ab33d57d4f37efb23847cee83934e565bf97c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:50:49 +0300 Subject: [PATCH 4/9] HW04_decorators Implement a performance decorator to measure execution time and memory usage. --- Week04/decorators_ozgun_kasapoglu.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Week04/decorators_ozgun_kasapoglu.py diff --git a/Week04/decorators_ozgun_kasapoglu.py b/Week04/decorators_ozgun_kasapoglu.py new file mode 100644 index 00000000..d1607547 --- /dev/null +++ b/Week04/decorators_ozgun_kasapoglu.py @@ -0,0 +1,30 @@ +import time +import tracemalloc + +tracemalloc.start() + + +def performance(func): + def wrapper(*args, **kwargs): + performance.counter += 1 + + tracemalloc.reset_peak() + + start_time = time.perf_counter() + + result = func(*args, **kwargs) + + end_time = time.perf_counter() + performance.total_time += (end_time - start_time) + + _, peak = tracemalloc.get_traced_memory() + performance.total_mem += peak + + return result + + return wrapper + + +performance.counter = 0 +performance.total_time = 0.0 +performance.total_mem = 0.0 From c1595561eafdaa45444201d5ae6102691f81a6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:52:03 +0300 Subject: [PATCH 5/9] HW04_functions Adds custom power and equation functions with type checks. --- Week04/functions_ozgun_kasapoglu.py | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Week04/functions_ozgun_kasapoglu.py diff --git a/Week04/functions_ozgun_kasapoglu.py b/Week04/functions_ozgun_kasapoglu.py new file mode 100644 index 00000000..34b857e1 --- /dev/null +++ b/Week04/functions_ozgun_kasapoglu.py @@ -0,0 +1,32 @@ +custom_power = lambda x=0, /, e=1: float(x ** e) + + +def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: + """ + Calculates (x**a + y**b) / c + + :param x: base for the first term + :param y: base for the second term + :param a: exponent for the first term + :param b: exponent for the second term + :param c: divisor for the sum + :return: the result of the equation as float + """ + if type(x) is not int: raise TypeError("x must be int") + if type(y) is not int: raise TypeError("y must be int") + if type(a) is not int: raise TypeError("a must be int") + if type(b) is not int: raise TypeError("b must be int") + if type(c) is not int: raise TypeError("c must be int") + return float((x ** a + y ** b) / c) + +_total = 0 +_counts = {} + + +def fn_w_counter() -> (int, dict[str, int]): + global _total, _counts + _total += 1 + caller = __name__ + _counts[caller] = _counts.get(caller, 0) + 1 + + return _total, _counts From 8e0f26fb3633fd125238401d4733529836f9ec27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:52:53 +0300 Subject: [PATCH 6/9] HW05 --- Week05/awaitme_ozgun_kasapoglu.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Week05/awaitme_ozgun_kasapoglu.py diff --git a/Week05/awaitme_ozgun_kasapoglu.py b/Week05/awaitme_ozgun_kasapoglu.py new file mode 100644 index 00000000..36cecc24 --- /dev/null +++ b/Week05/awaitme_ozgun_kasapoglu.py @@ -0,0 +1,5 @@ +def awaitme(func): + async def wrapper(*args, **kwargs): + return func(*args, **kwargs) + + return wrapper From 1e2e545a2710956b097d653bd6a6a14bfe8b8f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:53:51 +0300 Subject: [PATCH 7/9] HW06 Implement a Timer class for measuring elapsed time. --- Week06/timer_ozgun_kasapoglu.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Week06/timer_ozgun_kasapoglu.py diff --git a/Week06/timer_ozgun_kasapoglu.py b/Week06/timer_ozgun_kasapoglu.py new file mode 100644 index 00000000..fa2165ce --- /dev/null +++ b/Week06/timer_ozgun_kasapoglu.py @@ -0,0 +1,13 @@ +import time + +class Timer: + def __init__(self): + self.start_time = 0.0 + self.end_time = 0.0 + + def __enter__(self): + self.start_time = time.time() + return self + + def __exit__(self, a, b, c): + self.end_time = time.time() From 2fdf95bd1eadf4d4c754ceba41d369ec5106ddb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Wed, 8 Apr 2026 00:16:36 +0300 Subject: [PATCH 8/9] Fix HW04_decorator Added memory size calculation for function results. --- Week04/decorators_ozgun_kasapoglu.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Week04/decorators_ozgun_kasapoglu.py b/Week04/decorators_ozgun_kasapoglu.py index d1607547..a0e3a114 100644 --- a/Week04/decorators_ozgun_kasapoglu.py +++ b/Week04/decorators_ozgun_kasapoglu.py @@ -1,4 +1,5 @@ import time +import sys import tracemalloc tracemalloc.start() @@ -9,7 +10,6 @@ def wrapper(*args, **kwargs): performance.counter += 1 tracemalloc.reset_peak() - start_time = time.perf_counter() result = func(*args, **kwargs) @@ -18,7 +18,9 @@ def wrapper(*args, **kwargs): performance.total_time += (end_time - start_time) _, peak = tracemalloc.get_traced_memory() - performance.total_mem += peak + obj_size = sys.getsizeof(result) + + performance.total_mem += max(peak, obj_size) return result From ef84d11c980a9690d5e61b7a017d59d4e18cb735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20Kasapo=C4=9Flu?= <117996816+OzgunKasapoglu@users.noreply.github.com> Date: Wed, 8 Apr 2026 00:25:47 +0300 Subject: [PATCH 9/9] Fix HW04_functions --- Week04/functions_ozgun_kasapoglu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/functions_ozgun_kasapoglu.py b/Week04/functions_ozgun_kasapoglu.py index 34b857e1..5d942b29 100644 --- a/Week04/functions_ozgun_kasapoglu.py +++ b/Week04/functions_ozgun_kasapoglu.py @@ -24,7 +24,7 @@ def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int def fn_w_counter() -> (int, dict[str, int]): - global _total, _counts + global _total _total += 1 caller = __name__ _counts[caller] = _counts.get(caller, 0) + 1