From 168fc6b6c90368e702b28497980a0e0be84aeee1 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Wed, 7 Oct 2026 19:24:10 +0300 Subject: [PATCH 01/15] W2HW --- Week02/types_umut_turk.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Week02/types_umut_turk.py diff --git a/Week02/types_umut_turk.py b/Week02/types_umut_turk.py new file mode 100644 index 000000000..c3dbf5658 --- /dev/null +++ b/Week02/types_umut_turk.py @@ -0,0 +1,4 @@ +my_int = 1312 +my_float = 1157.25 +my_bool = True +my_complex = 4j+8 \ No newline at end of file From d648e992177636934f4af72677e0957b7d6d01ba Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Wed, 7 Oct 2026 20:29:48 +0300 Subject: [PATCH 02/15] W3HW --- Week03/pyramid_umut_turk.py | 11 ++++++++++ Week03/sequences.py | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 Week03/pyramid_umut_turk.py create mode 100644 Week03/sequences.py diff --git a/Week03/pyramid_umut_turk.py b/Week03/pyramid_umut_turk.py new file mode 100644 index 000000000..69b6f3bca --- /dev/null +++ b/Week03/pyramid_umut_turk.py @@ -0,0 +1,11 @@ +def calculate_pyramid_height(b_num): + a, b = 1, 0 + while b < b_num: + b += a+1 + a += 1 + + + return a-1 + +if __name__ == "__main__": + print(calculate_pyramid_height(15)) \ No newline at end of file diff --git a/Week03/sequences.py b/Week03/sequences.py new file mode 100644 index 000000000..c679adf53 --- /dev/null +++ b/Week03/sequences.py @@ -0,0 +1,40 @@ +def remove_duplicates(a_list): + my_list = a_list[:] + x = 1 + for i in my_list: + for j in my_list[x:]: + if i == j: + my_list.remove(i) + x -=1 + break + x +=1 + + return my_list +def list_counts(a_list): + my_list = a_list[:] + a = remove_duplicates(my_list) + my_dict = dict.fromkeys(a) + for i in a: + x = 0 + for j in a_list: + if i == j: + x += 1 + my_dict[i] = x + + return my_dict +def reverse_dict(a_dict): + my_dict = {} + a_list = list(a_dict) + b_list = list(a_dict.values()) + x = 0 + while x < len(a_list): + print(1) + my_dict[b_list[x]] = a_list[x] + x += 1 + + return my_dict + +if __name__ == "__main__": + print(remove_duplicates([1,5,4,4,4,6,41,54,54,41,6])) + print(list_counts([1,5,5,4,4,4,6,6,6,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6])) + print(reverse_dict(list_counts([1,5,5,4,4,4,6,6,6,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6]))) \ No newline at end of file From 1ec27195af099447faaf77626d69b51d98622d2a Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Wed, 7 Oct 2026 21:15:06 +0300 Subject: [PATCH 03/15] W3HWV2 --- Week03/sequences.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Week03/sequences.py b/Week03/sequences.py index c679adf53..ea98b8986 100644 --- a/Week03/sequences.py +++ b/Week03/sequences.py @@ -1,14 +1,13 @@ def remove_duplicates(a_list): my_list = a_list[:] - x = 1 - for i in my_list: - for j in my_list[x:]: - if i == j: - my_list.remove(i) - x -=1 - break - x +=1 - + for i in a_list: + x = True + for j, k in enumerate(my_list): + if i == k: + if x: + x = False + else: + del my_list[j] return my_list def list_counts(a_list): my_list = a_list[:] @@ -35,6 +34,6 @@ def reverse_dict(a_dict): return my_dict if __name__ == "__main__": - print(remove_duplicates([1,5,4,4,4,6,41,54,54,41,6])) + print(remove_duplicates([1,5,5,4,4,4,6,6,6,41,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6])) print(list_counts([1,5,5,4,4,4,6,6,6,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6])) print(reverse_dict(list_counts([1,5,5,4,4,4,6,6,6,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6]))) \ No newline at end of file From ca2b5fa61c64321a92fda6fad0edd3985f7064c1 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Wed, 7 Oct 2026 21:16:40 +0300 Subject: [PATCH 04/15] W3HWV3 --- Week03/{sequences.py => sequences_umut_turk.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Week03/{sequences.py => sequences_umut_turk.py} (100%) diff --git a/Week03/sequences.py b/Week03/sequences_umut_turk.py similarity index 100% rename from Week03/sequences.py rename to Week03/sequences_umut_turk.py From 3fe9bc892a6a84f35d580466bc54245752aad4e4 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 20 Oct 2026 11:39:26 +0300 Subject: [PATCH 05/15] W5HWV4 --- Week04/decorators_umut_turk.py | 0 Week04/functions_umut_turk.py | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Week04/decorators_umut_turk.py create mode 100644 Week04/functions_umut_turk.py diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py new file mode 100644 index 000000000..e69de29bb diff --git a/Week04/functions_umut_turk.py b/Week04/functions_umut_turk.py new file mode 100644 index 000000000..822b67814 --- /dev/null +++ b/Week04/functions_umut_turk.py @@ -0,0 +1,25 @@ +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: + """_summary_ + + Args: + x (int, optional): _description_. Defaults to 0. positional only + y (int, optional): _description_. Defaults to 0. positional only + a (int, optional): _description_. Defaults to 1. positional or keyword + b (int, optional): _description_. Defaults to 1. positional or keyword + c (int, optional): _description_. Defaults to 1. keyword only + + Returns: + float: _description_ + x**a + y**b / c + """ + return (x**a + y**b) / c + +def fn_w_counter(): + if not hasattr(fn_w_counter, "counter"): + fn_w_counter.counter = 0 + fn_w_counter.counter += 1 + return (fn_w_counter.counter, {fn_w_counter.__module__: fn_w_counter.counter}) +if __name__ == "__main__": + print(fn_w_counter()) \ No newline at end of file From 8716de6ec2f3d6b3f086435d29a97bdd51af53b5 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 20 Oct 2026 11:42:22 +0300 Subject: [PATCH 06/15] W5HWV4 --- Week04/functions_umut_turk.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Week04/functions_umut_turk.py b/Week04/functions_umut_turk.py index 822b67814..cdf187452 100644 --- a/Week04/functions_umut_turk.py +++ b/Week04/functions_umut_turk.py @@ -1,18 +1,22 @@ 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: - """_summary_ + """Calculate custom polynomial equation result. - Args: - x (int, optional): _description_. Defaults to 0. positional only - y (int, optional): _description_. Defaults to 0. positional only - a (int, optional): _description_. Defaults to 1. positional or keyword - b (int, optional): _description_. Defaults to 1. positional or keyword - c (int, optional): _description_. Defaults to 1. keyword only + Calculates :math:`\\frac{x^a + y^b}{c}`. - Returns: - float: _description_ - x**a + y**b / c + :param x: Positional-only x value, defaults to 0 + :type x: int, optional + :param y: Positional-only y value, defaults to 0 + :type y: int, optional + :param a: Positional-or-keyword exponent for x, defaults to 1 + :type a: int, optional + :param b: Positional-or-keyword exponent for y, defaults to 1 + :type b: int, optional + :param c: Keyword-only denominator, defaults to 1 + :type c: int, optional + :return: Result of (x**a + y**b) / c + :rtype: float """ return (x**a + y**b) / c From 3b418c54402e71ef1a2a24067af6a3a390052519 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 20 Oct 2026 11:46:59 +0300 Subject: [PATCH 07/15] W5HWV4 --- Week04/functions_umut_turk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/functions_umut_turk.py b/Week04/functions_umut_turk.py index cdf187452..8fc432c8b 100644 --- a/Week04/functions_umut_turk.py +++ b/Week04/functions_umut_turk.py @@ -20,7 +20,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(): +def fn_w_counter() -> tuple[str, dict]: if not hasattr(fn_w_counter, "counter"): fn_w_counter.counter = 0 fn_w_counter.counter += 1 From 20b779902a39dddc3e68000ac6daf4b51f011797 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 20 Oct 2026 11:49:17 +0300 Subject: [PATCH 08/15] W5HWV4 --- Week04/functions_umut_turk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/functions_umut_turk.py b/Week04/functions_umut_turk.py index 8fc432c8b..fb9bf2bf5 100644 --- a/Week04/functions_umut_turk.py +++ b/Week04/functions_umut_turk.py @@ -20,7 +20,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[str, dict]: +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 From 2d45101061377bcbbe9522087c6e1c32adfda713 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 3 Nov 2026 13:51:34 +0300 Subject: [PATCH 09/15] W5HWV4V2 --- Week04/decorators_umut_turk.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py index e69de29bb..1be668b3e 100644 --- a/Week04/decorators_umut_turk.py +++ b/Week04/decorators_umut_turk.py @@ -0,0 +1,14 @@ +import time +import tracemalloc + +def performance(f): + def _performance(): + if not hasattr(_performance, "counter"): + counter = 0 + _performance.counter += 1 + x = time.time() + tracemalloc.start() + f() + total_mem = tracemalloc.get_traced_memory + total_time = time.time() - x + tracemalloc.stop \ No newline at end of file From ae6962b780e282db1aca7c1889cefcd5ab7c08f5 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 3 Nov 2026 13:54:58 +0300 Subject: [PATCH 10/15] W5HWV4V2 --- Week04/decorators_umut_turk.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py index 1be668b3e..e441f188b 100644 --- a/Week04/decorators_umut_turk.py +++ b/Week04/decorators_umut_turk.py @@ -2,13 +2,14 @@ import tracemalloc def performance(f): - def _performance(): + def _performance(*args, **kwargs): if not hasattr(_performance, "counter"): counter = 0 _performance.counter += 1 x = time.time() tracemalloc.start() - f() + f(args, kwargs) total_mem = tracemalloc.get_traced_memory total_time = time.time() - x - tracemalloc.stop \ No newline at end of file + tracemalloc.stop + return _performance \ No newline at end of file From 4eb0340c9dbf6e2a37610ad7555c4ba5404e86a3 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 3 Nov 2026 13:56:46 +0300 Subject: [PATCH 11/15] W5HWV4V2 --- Week04/decorators_umut_turk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py index e441f188b..4acbb7cd4 100644 --- a/Week04/decorators_umut_turk.py +++ b/Week04/decorators_umut_turk.py @@ -4,7 +4,7 @@ def performance(f): def _performance(*args, **kwargs): if not hasattr(_performance, "counter"): - counter = 0 + _performance.counter = 0 _performance.counter += 1 x = time.time() tracemalloc.start() From 31c379384073bc16234dbcdbbb773e78b3f59663 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 3 Nov 2026 13:58:50 +0300 Subject: [PATCH 12/15] W5HWV4V2 --- Week04/decorators_umut_turk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py index 4acbb7cd4..40b14ae10 100644 --- a/Week04/decorators_umut_turk.py +++ b/Week04/decorators_umut_turk.py @@ -6,10 +6,10 @@ def _performance(*args, **kwargs): if not hasattr(_performance, "counter"): _performance.counter = 0 _performance.counter += 1 - x = time.time() tracemalloc.start() + x = time.time() f(args, kwargs) - total_mem = tracemalloc.get_traced_memory total_time = time.time() - x + total_mem = tracemalloc.get_traced_memory tracemalloc.stop return _performance \ No newline at end of file From fca01d9db54cbb7ec7683fa21005bc3338ddb3a9 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 3 Nov 2026 14:02:54 +0300 Subject: [PATCH 13/15] W5HWV4V2 --- Week04/decorators_umut_turk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py index 40b14ae10..f0bfab350 100644 --- a/Week04/decorators_umut_turk.py +++ b/Week04/decorators_umut_turk.py @@ -8,8 +8,8 @@ def _performance(*args, **kwargs): _performance.counter += 1 tracemalloc.start() x = time.time() - f(args, kwargs) + f(*args, **kwargs) total_time = time.time() - x - total_mem = tracemalloc.get_traced_memory - tracemalloc.stop + total_mem = tracemalloc.get_traced_memory() + tracemalloc.stop() return _performance \ No newline at end of file From a74a6e937512b521a7ab5daa676bed5e4ab4d454 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 3 Nov 2026 14:16:30 +0300 Subject: [PATCH 14/15] W5HWV4V2 --- Week04/decorators_umut_turk.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py index f0bfab350..201dae231 100644 --- a/Week04/decorators_umut_turk.py +++ b/Week04/decorators_umut_turk.py @@ -2,14 +2,25 @@ import tracemalloc def performance(f): + if not hasattr(performance, "counter"): + performance.counter = 0 + + if not hasattr(performance, "total_time"): + performance.total_time = 0.0 + + if not hasattr(performance, "total_mem"): + performance.total_mem = 0 + def _performance(*args, **kwargs): - if not hasattr(_performance, "counter"): - _performance.counter = 0 - _performance.counter += 1 + performance.counter += 1 + tracemalloc.start() + x = time.time() - f(*args, **kwargs) - total_time = time.time() - x - total_mem = tracemalloc.get_traced_memory() + + ret = f(*args, **kwargs) + performance.total_time = time.time() - x + performance.total_mem = tracemalloc.get_traced_memory()[1] tracemalloc.stop() + return ret return _performance \ No newline at end of file From 785615986fb8e769303e0faeda31b1dba2c22f10 Mon Sep 17 00:00:00 2001 From: Umut <230315070@ogr.cbu.edu.tr> Date: Tue, 3 Nov 2026 15:26:41 +0300 Subject: [PATCH 15/15] W5HWV4V2 --- Week04/decorators_umut_turk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py index 201dae231..f28042c1b 100644 --- a/Week04/decorators_umut_turk.py +++ b/Week04/decorators_umut_turk.py @@ -19,7 +19,7 @@ def _performance(*args, **kwargs): x = time.time() ret = f(*args, **kwargs) - performance.total_time = time.time() - x + performance.total_time += time.time() - x performance.total_mem = tracemalloc.get_traced_memory()[1] tracemalloc.stop() return ret