From 1f9b59507aa47db045d334769b5a63c213d65c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:03:42 +0300 Subject: [PATCH 01/10] Create info_umut_sahin.py --- Week01/info_umut_sahin.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Week01/info_umut_sahin.py diff --git a/Week01/info_umut_sahin.py b/Week01/info_umut_sahin.py new file mode 100644 index 00000000..ea6274a0 --- /dev/null +++ b/Week01/info_umut_sahin.py @@ -0,0 +1,2 @@ +student_id = "220316051" +full_name = "Umut Şahin" From aff245dd35c90f24718045f11cc58f7be12af79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:04:52 +0300 Subject: [PATCH 02/10] Create types_umut_sahin.py --- Week02/types_umut_sahin.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Week02/types_umut_sahin.py diff --git a/Week02/types_umut_sahin.py b/Week02/types_umut_sahin.py new file mode 100644 index 00000000..cb513e5b --- /dev/null +++ b/Week02/types_umut_sahin.py @@ -0,0 +1,4 @@ +my_int = 47 +my_float = 2 / 1 +my_bool = True +my_complex = 3j From 2ea8401e42ef62aa8e77585d11036b68bab792bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:06:05 +0300 Subject: [PATCH 03/10] Create pyramid_umut_sahin.py --- Week03/pyramid_umut_sahin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Week03/pyramid_umut_sahin.py diff --git a/Week03/pyramid_umut_sahin.py b/Week03/pyramid_umut_sahin.py new file mode 100644 index 00000000..832a02a8 --- /dev/null +++ b/Week03/pyramid_umut_sahin.py @@ -0,0 +1,10 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + n = 0 + while True: + blocks_needed = (n * (n + 1)) // 2 + if blocks_needed > number_of_blocks: + break + height = n + n += 1 + return height From d4f5958505f5c476f597fb413cee632022ebf930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:10:21 +0300 Subject: [PATCH 04/10] Create decorators_umut_sahin.py --- Week04/decorators_umut_sahin.py | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Week04/decorators_umut_sahin.py diff --git a/Week04/decorators_umut_sahin.py b/Week04/decorators_umut_sahin.py new file mode 100644 index 00000000..a121f83c --- /dev/null +++ b/Week04/decorators_umut_sahin.py @@ -0,0 +1,34 @@ +import time +import tracemalloc + +def performance(fn): + """A decorator to measure the performance (time and memory usage) of a function.""" + # Static variables for performance tracking + if not hasattr(performance, "counter"): + performance.counter = 0 + performance.total_time = 0 + performance.total_mem = 0 + + def wrapper(*args, **kwargs): + # Increment the call counter + performance.counter += 1 + + # Start tracking memory and time + tracemalloc.start() + start_time = time.time() + + # Execute the decorated function + result = fn(*args, **kwargs) + + # Stop tracking memory and calculate elapsed time + end_time = time.time() + current, peak = tracemalloc.get_traced_memory() + tracemalloc.stop() + + # Update total memory and time + performance.total_mem += peak + performance.total_time += (end_time - start_time) + + return result + + return wrapper From ca2d695a7e1fbecc5a32751df4c5650875ee9a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:11:31 +0300 Subject: [PATCH 05/10] Create awaitme_umut_sahin.py --- Week05/Week05/awaitme_umut_sahin.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Week05/Week05/awaitme_umut_sahin.py diff --git a/Week05/Week05/awaitme_umut_sahin.py b/Week05/Week05/awaitme_umut_sahin.py new file mode 100644 index 00000000..7f7f7c53 --- /dev/null +++ b/Week05/Week05/awaitme_umut_sahin.py @@ -0,0 +1,9 @@ +import asyncio + +def awaitme(function): + async def wrapper(*args, **kwargs): + result = function(*args, **kwargs) + if asyncio.iscoroutine(result): + return await result + return result + return wrapper From f54fab1a58f688130917d5aceaba92f9ac5dea62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:12:55 +0300 Subject: [PATCH 06/10] Delete Week05/Week05 directory --- Week05/Week05/awaitme_umut_sahin.py | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 Week05/Week05/awaitme_umut_sahin.py diff --git a/Week05/Week05/awaitme_umut_sahin.py b/Week05/Week05/awaitme_umut_sahin.py deleted file mode 100644 index 7f7f7c53..00000000 --- a/Week05/Week05/awaitme_umut_sahin.py +++ /dev/null @@ -1,9 +0,0 @@ -import asyncio - -def awaitme(function): - async def wrapper(*args, **kwargs): - result = function(*args, **kwargs) - if asyncio.iscoroutine(result): - return await result - return result - return wrapper From 778eca11e509d6c7240412f65002b76d91f62cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:14:10 +0300 Subject: [PATCH 07/10] Create awaitme_umut_sahin.py --- Week05/awaitme_umut_sahin.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Week05/awaitme_umut_sahin.py diff --git a/Week05/awaitme_umut_sahin.py b/Week05/awaitme_umut_sahin.py new file mode 100644 index 00000000..7f7f7c53 --- /dev/null +++ b/Week05/awaitme_umut_sahin.py @@ -0,0 +1,9 @@ +import asyncio + +def awaitme(function): + async def wrapper(*args, **kwargs): + result = function(*args, **kwargs) + if asyncio.iscoroutine(result): + return await result + return result + return wrapper From 7bdbe3b5978e8512acdf0f3489b9318183c40fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:16:56 +0300 Subject: [PATCH 08/10] Delete Week04/decorators_umut_sahin.py --- Week04/decorators_umut_sahin.py | 34 --------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 Week04/decorators_umut_sahin.py diff --git a/Week04/decorators_umut_sahin.py b/Week04/decorators_umut_sahin.py deleted file mode 100644 index a121f83c..00000000 --- a/Week04/decorators_umut_sahin.py +++ /dev/null @@ -1,34 +0,0 @@ -import time -import tracemalloc - -def performance(fn): - """A decorator to measure the performance (time and memory usage) of a function.""" - # Static variables for performance tracking - if not hasattr(performance, "counter"): - performance.counter = 0 - performance.total_time = 0 - performance.total_mem = 0 - - def wrapper(*args, **kwargs): - # Increment the call counter - performance.counter += 1 - - # Start tracking memory and time - tracemalloc.start() - start_time = time.time() - - # Execute the decorated function - result = fn(*args, **kwargs) - - # Stop tracking memory and calculate elapsed time - end_time = time.time() - current, peak = tracemalloc.get_traced_memory() - tracemalloc.stop() - - # Update total memory and time - performance.total_mem += peak - performance.total_time += (end_time - start_time) - - return result - - return wrapper From 26e058cabf7d92bcedbd785c131756add65686fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:18:16 +0300 Subject: [PATCH 09/10] Create functions_umut_sahin.py --- Week04/functions_umut_sahin.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Week04/functions_umut_sahin.py diff --git a/Week04/functions_umut_sahin.py b/Week04/functions_umut_sahin.py new file mode 100644 index 00000000..37e9d111 --- /dev/null +++ b/Week04/functions_umut_sahin.py @@ -0,0 +1,29 @@ +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: + """ + This function raises x to the power of a, y to the power of b, sums them, and then divides the result by c. + + :param x: The positional-only integer base parameter for the equation , default is 0 + :param y: The positional-only integer base parameter for the equation , default is 0 + :param a: The positional-or-keyword integer exponent parameter for the equation , default is 1 + :param b: The positional-or-keyword integer exponent parameter for the equation , default is 1 + :param c: The keyword-only integer divisor parameter for the equation , default is 1 + :return: The result of the calculation as a float and the equation is (x**a + y**b) / c + :rtype: float + """ + return (x**a + y**b) / c + + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter,'_call_counter'): + fn_w_counter._call_counter = 0 + fn_w_counter._caller_dict = {} + caller = __name__ + fn_w_counter._call_counter += 1 + if caller in fn_w_counter._caller_dict: + fn_w_counter._caller_dict[caller] += 1 + else: + fn_w_counter._caller_dict[caller] = 1 + return fn_w_counter._call_counter,fn_w_counter._caller_dict From cc87dc0a7f00f17b9371685d2c949a112eae7dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20=C5=9Eahin?= Date: Fri, 3 Apr 2026 22:18:59 +0300 Subject: [PATCH 10/10] Create decorators_umut_sahin.py --- Week04/decorators_umut_sahin.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Week04/decorators_umut_sahin.py diff --git a/Week04/decorators_umut_sahin.py b/Week04/decorators_umut_sahin.py new file mode 100644 index 00000000..f598313e --- /dev/null +++ b/Week04/decorators_umut_sahin.py @@ -0,0 +1,32 @@ +import tracemalloc, time + +def performance(func): + """ + Decorator to track function performance and record statistics. + + :param func: Function to decorate. + :type func: callable + :return: Wrapped function. + :rtype: callable + + :cvar counter: Number of calls. + :cvar total_time: Total execution time in seconds. + :cvar total_mem: Total peak memory in bytes. + """ + performance.counter = 0 + performance.total_time = 0.0 + performance.total_mem = 0.0 + + def wrapper(*args, **kwargs): + tracemalloc.start() + start_time = time.time() + result = func(*args, **kwargs) + end_time = time.time() + current, peak = tracemalloc.get_traced_memory() + tracemalloc.stop() + performance.counter += 1 + performance.total_time += (end_time - start_time) + performance.total_mem += peak + return result + + return wrapper