From a7675c703abf327184d8811cfd0364be5ef80e9c Mon Sep 17 00:00:00 2001 From: elifgulseren Date: Mon, 2 Nov 2026 23:13:03 +0300 Subject: [PATCH 1/4] Create pyramid_elif_gulseren.py --- Week03/pyramid_elif_gulseren.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Week03/pyramid_elif_gulseren.py diff --git a/Week03/pyramid_elif_gulseren.py b/Week03/pyramid_elif_gulseren.py new file mode 100644 index 00000000..f06be4ae --- /dev/null +++ b/Week03/pyramid_elif_gulseren.py @@ -0,0 +1,10 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + layer_blocks = 1 + + while number_of_blocks >= layer_blocks: + number_of_blocks -= layer_blocks + height += 1 + layer_blocks += 1 + + return height From 2490212f9b5c9d08a280f510d258038bbc01df00 Mon Sep 17 00:00:00 2001 From: elifgulseren Date: Mon, 2 Nov 2026 23:22:17 +0300 Subject: [PATCH 2/4] Create sequences_elif_gulseren.py --- Week03/sequences_elif_gulseren.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Week03/sequences_elif_gulseren.py diff --git a/Week03/sequences_elif_gulseren.py b/Week03/sequences_elif_gulseren.py new file mode 100644 index 00000000..e1114553 --- /dev/null +++ b/Week03/sequences_elif_gulseren.py @@ -0,0 +1,31 @@ +def remove_duplicates(seq: list) -> list: + """ + This function removes duplicates from a list. + """ + result = [] + for item in seq: + if item not in result: + result.append(item) + return result + + +def list_counts(seq: list) -> dict: + """ + This function counts the number of + occurrences of each item in a list. + """ + counts = {} + for item in seq: + counts[item] = counts.get(item, 0) + 1 + return counts + + +def reverse_dict(d: dict) -> dict: + """ + This function reverses the keys + and values of a dictionary. + """ + reversed_d = {} + for k, v in d.items(): + reversed_d[v] = k + return reversed_d From 25bda4df628fedd2ad0d46edcb0d629c21412c59 Mon Sep 17 00:00:00 2001 From: elifgulseren Date: Fri, 6 Nov 2026 23:12:26 +0300 Subject: [PATCH 3/4] Create functions_elif_gulseren.py --- Week04/functions_elif_gulseren.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Week04/functions_elif_gulseren.py diff --git a/Week04/functions_elif_gulseren.py b/Week04/functions_elif_gulseren.py new file mode 100644 index 00000000..fcbf75dc --- /dev/null +++ b/Week04/functions_elif_gulseren.py @@ -0,0 +1,32 @@ +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: + """ + Calculates the result of a custom mathematical equation. + + :param x: The first base (positional-only). + :param y: The second base (positional-only). + :param a: The exponent for the first base (positional-or-keyword). + :param b: The exponent for the second base (positional-or-keyword). + :param c: The divisor (keyword-only). + :return: The result of the equation (x**a + y**b) / c as a float. + """ + if type(x) is not int or type(y) is not int or type(a) is not int or type(b) is not int or type(c) is not int: + raise TypeError("All arguments must be integers.") + + return float((x ** a + y ** b) / c) + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "total_calls"): + fn_w_counter.total_calls = 0 + fn_w_counter.caller_dict = {} + + fn_w_counter.total_calls += 1 + + caller = __name__ + + if caller not in fn_w_counter.caller_dict: + fn_w_counter.caller_dict[caller] = 0 + fn_w_counter.caller_dict[caller] += 1 + + return fn_w_counter.total_calls, fn_w_counter.caller_dict From 16661f08086370809a3cec036736aea029508c6e Mon Sep 17 00:00:00 2001 From: elifgulseren Date: Sat, 7 Nov 2026 23:45:17 +0300 Subject: [PATCH 4/4] Create decorators_elif_gulseren.py --- Week04/decorators_elif_gulseren.py | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Week04/decorators_elif_gulseren.py diff --git a/Week04/decorators_elif_gulseren.py b/Week04/decorators_elif_gulseren.py new file mode 100644 index 00000000..5ea27fb2 --- /dev/null +++ b/Week04/decorators_elif_gulseren.py @@ -0,0 +1,34 @@ +import time +import tracemalloc +from functools import wraps + +def performance(func): + @wraps(func) + def wrapper(*args, **kwargs): + performance.counter += 1 + + tracemalloc.start() + start_mem, _ = tracemalloc.get_traced_memory() + + start_time = time.perf_counter() + + result = func(*args, **kwargs) + + end_time = time.perf_counter() + + _, peak_mem = tracemalloc.get_traced_memory() + tracemalloc.stop() + + time_taken = end_time - start_time + mem_used = peak_mem - start_mem + + performance.total_time += time_taken + performance.total_mem += mem_used + + return result + + return wrapper + +performance.counter = 0 +performance.total_time = 0.0 +performance.total_mem = 0