From b79517e86e249f901ad1e080161e1a8ab2e4c033 Mon Sep 17 00:00:00 2001 From: mirza-ceng <2005mirza2005@gmail.com> Date: Tue, 22 Sep 2026 17:34:38 +0300 Subject: [PATCH 1/4] WEEK 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FİRST COMMİT --- Week01/info_mirza_german.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Week01/info_mirza_german.py diff --git a/Week01/info_mirza_german.py b/Week01/info_mirza_german.py new file mode 100644 index 000000000..72864c2ab --- /dev/null +++ b/Week01/info_mirza_german.py @@ -0,0 +1,2 @@ +student_id="230316056" +full_name="Senai Mirza German" \ No newline at end of file From 5c3992e86404df01199e3078210a0b4113c2e4d7 Mon Sep 17 00:00:00 2001 From: mirza-ceng <2005mirza2005@gmail.com> Date: Wed, 18 Nov 2026 20:48:11 +0300 Subject: [PATCH 2/4] Fix spacing in student_id and full_name assignments --- Week01/info_mirza_german.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Week01/info_mirza_german.py b/Week01/info_mirza_german.py index 72864c2ab..b6ee6704b 100644 --- a/Week01/info_mirza_german.py +++ b/Week01/info_mirza_german.py @@ -1,2 +1,2 @@ -student_id="230316056" -full_name="Senai Mirza German" \ No newline at end of file +student_id = "230316056" +full_name = "Senai Mirza German" From e548716649d9798d7b890fd9909284d93641747a Mon Sep 17 00:00:00 2001 From: Mirza German <2005mirza2005@gmail.com> Date: Wed, 18 Nov 2026 21:01:43 +0300 Subject: [PATCH 3/4] commit for week 2 --- Week02/types_mirza_german.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Week02/types_mirza_german.py diff --git a/Week02/types_mirza_german.py b/Week02/types_mirza_german.py new file mode 100644 index 000000000..3916ff8cd --- /dev/null +++ b/Week02/types_mirza_german.py @@ -0,0 +1,4 @@ +my_int = 10 +my_float = 3.14 +my_bool = True +my_complex = 2 + 3j \ No newline at end of file From 1839a9ca2240d878a2bffc669d2a052fc1f4499b Mon Sep 17 00:00:00 2001 From: Mirza German <2005mirza2005@gmail.com> Date: Thu, 19 Nov 2026 08:47:06 +0300 Subject: [PATCH 4/4] . --- Week03/pyramid_mirza_german.py | 10 ++++++++ Week03/sequences_mirza_german.py | 21 +++++++++++++++++ Week04/decorators_mirza_german.py | 32 ++++++++++++++++++++++++++ Week04/functions_mirza_german.py | 38 +++++++++++++++++++++++++++++++ Week05/emails_mirza_german.py | 30 ++++++++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 Week03/pyramid_mirza_german.py create mode 100644 Week03/sequences_mirza_german.py create mode 100644 Week04/decorators_mirza_german.py create mode 100644 Week04/functions_mirza_german.py create mode 100644 Week05/emails_mirza_german.py diff --git a/Week03/pyramid_mirza_german.py b/Week03/pyramid_mirza_german.py new file mode 100644 index 000000000..62ec767f7 --- /dev/null +++ b/Week03/pyramid_mirza_german.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 \ No newline at end of file diff --git a/Week03/sequences_mirza_german.py b/Week03/sequences_mirza_german.py new file mode 100644 index 000000000..dd4d3818f --- /dev/null +++ b/Week03/sequences_mirza_german.py @@ -0,0 +1,21 @@ +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: + if item in counts: + counts[item] += 1 + else: + counts[item] = 1 + return counts + +def reverse_dict(d: dict) -> dict: + reversed_d = {} + for key, value in d.items(): + reversed_d[value] = key + return reversed_d diff --git a/Week04/decorators_mirza_german.py b/Week04/decorators_mirza_german.py new file mode 100644 index 000000000..e74c73fd6 --- /dev/null +++ b/Week04/decorators_mirza_german.py @@ -0,0 +1,32 @@ +import time +import tracemalloc + + +def performance(fn): + """ + Decorator that measures the execution time and memory usage of a function. + Statistics are kept in performance.counter, performance.total_time + and performance.total_mem. + """ + def wrapper(*args, **kwargs): + tracemalloc.start() + begin = time.time() + try: + output = fn(*args, **kwargs) + finally: + end = time.time() + used = tracemalloc.get_traced_memory()[1] + tracemalloc.stop() + performance.counter += 1 + performance.total_time += end - begin + performance.total_mem += used + return output + + wrapper.__name__ = fn.__name__ + wrapper.__doc__ = fn.__doc__ + return wrapper + + +performance.counter = 0 +performance.total_time = 0 +performance.total_mem = 0 diff --git a/Week04/functions_mirza_german.py b/Week04/functions_mirza_german.py new file mode 100644 index 000000000..07f59ea4d --- /dev/null +++ b/Week04/functions_mirza_german.py @@ -0,0 +1,38 @@ +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: + """ + Raises x to the power a and y to the power b, adds them and divides by c. + + :param x: Base of the first term (positional-only) + :type x: int + :param y: Base of the second term (positional-only) + :type y: int + :param a: Power applied to x + :type a: int + :param b: Power applied to y + :type b: int + :param c: Number to divide the sum by (keyword-only) + :type c: int + :return: The calculated value + :rtype: float + """ + for name, value in (("x", x), ("y", y), ("a", a), ("b", b), ("c", c)): + if type(value) is not int: + raise TypeError(f"{name} must be an int") + return float((x ** a + y ** b) / c) + + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "call_count"): + fn_w_counter.call_count = 0 + fn_w_counter.callers = {} + + fn_w_counter.call_count += 1 + if __name__ in fn_w_counter.callers: + fn_w_counter.callers[__name__] += 1 + else: + fn_w_counter.callers[__name__] = 1 + + return fn_w_counter.call_count, fn_w_counter.callers diff --git a/Week05/emails_mirza_german.py b/Week05/emails_mirza_german.py new file mode 100644 index 000000000..37bbcc493 --- /dev/null +++ b/Week05/emails_mirza_german.py @@ -0,0 +1,30 @@ +class Emails(list): + def __init__(self, email_list): + checked = self.validate(email_list) + super().__init__(checked) + self.data = checked + + def validate(self, email_list): + result = [] + for item in email_list: + if type(item) is not str: + raise ValueError("Only strings are allowed") + if item.count("@") != 1: + raise ValueError("Invalid email: " + item) + user, domain = item.split("@") + if user == "" or "." not in domain: + raise ValueError("Invalid email: " + item) + if domain.startswith(".") or domain.endswith("."): + raise ValueError("Invalid email: " + item) + if item not in result: + result.append(item) + return result + + def __repr__(self): + return "Emails(" + str(list(self)) + ")" + + def __str__(self): + text = "Emails:\n" + for i, mail in enumerate(self, start=1): + text += f"{i}. {mail}\n" + return text