From 08d7b9fbf709b0a5e516b00a6342b313aa8f2119 Mon Sep 17 00:00:00 2001 From: Cem AYYILDIZ Date: Wed, 18 Nov 2026 10:47:44 +0300 Subject: [PATCH 1/4] Add functions for removing duplicates and counting items --- Week03/sequences_cem_ayyildiz.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Week03/sequences_cem_ayyildiz.py diff --git a/Week03/sequences_cem_ayyildiz.py b/Week03/sequences_cem_ayyildiz.py new file mode 100644 index 00000000..8d4017de --- /dev/null +++ b/Week03/sequences_cem_ayyildiz.py @@ -0,0 +1,15 @@ +def remove_duplicates(seq: list) -> list: + result = [] + for item in seq: + if item not in result: + result.append(item) + return result + +def list_counts(seq: list) -> dict: + counts = {} + for item in seq: + counts[item] = counts.get(item, 0) + 1 + return counts + +def reverse_dict(d: dict) -> dict: + return {v: k for k, v in d.items()} From 7a4b137c66993c34cb4bf89a914e4592fc648b35 Mon Sep 17 00:00:00 2001 From: Cem AYYILDIZ Date: Wed, 18 Nov 2026 10:49:46 +0300 Subject: [PATCH 2/4] Add performance decorator with time and memory tracking Implement a performance decorator to track execution time and memory usage. --- Week04/decorators_cem_ayyildiz.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Week04/decorators_cem_ayyildiz.py diff --git a/Week04/decorators_cem_ayyildiz.py b/Week04/decorators_cem_ayyildiz.py new file mode 100644 index 00000000..309a0706 --- /dev/null +++ b/Week04/decorators_cem_ayyildiz.py @@ -0,0 +1,30 @@ +import time +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): + + performance.counter += 1 + + tracemalloc.start() + x = time.time() + + + ret = f(*args, **kwargs) + + + performance.total_time += time.time() - x + + performance.total_mem = tracemalloc.get_traced_memory()[1] + + tracemalloc.stop() + + return ret + return _performance From 5ba4c3a828d71c0017a395356549cf18125e83d5 Mon Sep 17 00:00:00 2001 From: Cem AYYILDIZ Date: Wed, 18 Nov 2026 10:51:10 +0300 Subject: [PATCH 3/4] Implement custom power and equation functions Added custom_power function and custom_equation for calculations. --- Week04/functions_cem_ayyildiz.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Week04/functions_cem_ayyildiz.py diff --git a/Week04/functions_cem_ayyildiz.py b/Week04/functions_cem_ayyildiz.py new file mode 100644 index 00000000..64c7ae18 --- /dev/null +++ b/Week04/functions_cem_ayyildiz.py @@ -0,0 +1,34 @@ +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 equation (x**a + y**b) / c. + + :param x: The base of the first term, positional-only + :type x: int + :param y: The base of the second term, positional-only + :type y: int + :param a: The exponent of the first term + :type a: int + :param b: The exponent of the second term + :type b: int + :param c: The divisor, keyword-only + :type c: int + :return: The result of (x**a + y**b) / c + + """ + + return (x**a + y**b) / c + + +_total_calls = 0 +_calls_by_caller = {} + + +def fn_w_counter() -> (int, dict[str, int]): + + global _total_calls + _total_calls += 1 + _calls_by_caller[__name__] = _calls_by_caller.get(__name__, 0) + 1 + return _total_calls, dict(_calls_by_caller) From 6a6a39f87955ee43de782ee7669a49ce48768b51 Mon Sep 17 00:00:00 2001 From: Cem AYYILDIZ Date: Wed, 18 Nov 2026 10:56:25 +0300 Subject: [PATCH 4/4] Implement Emails class for email validation and storage --- Week05/email_cem_ayyildiz.py | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Week05/email_cem_ayyildiz.py diff --git a/Week05/email_cem_ayyildiz.py b/Week05/email_cem_ayyildiz.py new file mode 100644 index 00000000..b2ec235b --- /dev/null +++ b/Week05/email_cem_ayyildiz.py @@ -0,0 +1,37 @@ + +import re + + +class Emails(list): + + def __init__(self, emails): + self.data = [] + + for email in emails: + if not isinstance(email, str): + raise ValueError("Only strings are allowed") + + self.validate(email) + + if email not in self.data: + self.data.append(email) + + super().__init__(self.data) + + @staticmethod + def validate(email): + if not isinstance(email, str): + raise ValueError("Email must be a string") + + pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$' + + if not re.match(pattern, email): + raise ValueError("Invalid email address") + + return True + + def __repr__(self): + return f"Emails({self.data!r})" + + def __str__(self): + return ", ".join(self.data)