diff --git a/Week01/info_muhammet_taha_parlak.py b/Week01/info_muhammet_taha_parlak.py new file mode 100644 index 00000000..78a60803 --- /dev/null +++ b/Week01/info_muhammet_taha_parlak.py @@ -0,0 +1,4 @@ +# Week01/info_muhammet_taha_parlak.py + +student_id = "210316058" +full_name = "Muhammet Taha Parlak" diff --git a/Week02/types_muhammet_taha_parlak.py b/Week02/types_muhammet_taha_parlak.py new file mode 100644 index 00000000..714d4140 --- /dev/null +++ b/Week02/types_muhammet_taha_parlak.py @@ -0,0 +1,6 @@ +# Week02/types_muhammet_taha_parlak.py + +my_int = 7 # Tam sayı (Integer) [cite: 251] +my_float = 7.0 # Ondalıklı sayı (Float) [cite: 252] +my_bool = True # Mantıksal değer (Boolean) [cite: 253] +my_complex = 7 + 0j # Karmaşık sayı (Complex) [cite: 254] diff --git a/Week03/pyramid_muhammet_taha_parlak.py b/Week03/pyramid_muhammet_taha_parlak.py new file mode 100644 index 00000000..059d5cc6 --- /dev/null +++ b/Week03/pyramid_muhammet_taha_parlak.py @@ -0,0 +1,10 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + layer = 1 + + while number_of_blocks >= layer: + number_of_blocks -= layer + height += 1 + layer += 1 + + return height diff --git a/Week03/sequences_muhammet_taha_parlak.py b/Week03/sequences_muhammet_taha_parlak.py new file mode 100644 index 00000000..2663740d --- /dev/null +++ b/Week03/sequences_muhammet_taha_parlak.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: + if item in counts: + counts[item] += 1 + else: + counts[item] = 1 + return counts + +def reverse_dict(d: dict) -> dict: + """ + This function reverses the keys and values of a dictionary. + """ + reversed_d = {} + for key, value in d.items(): + + reversed_d[value] = key + return reversed_d diff --git a/Week04/decorators_muhammet_taha_parlak.py b/Week04/decorators_muhammet_taha_parlak.py new file mode 100644 index 00000000..b5a7a8cd --- /dev/null +++ b/Week04/decorators_muhammet_taha_parlak.py @@ -0,0 +1,21 @@ +import time +import tracemalloc + +def performance(func): + + performance.counter = 0 + performance.total_time = 0 + performance.total_mem = 0 + + def init(*args,**kwargs): + start_time = time.time() + tracemalloc.start() + res = func(*args,**kwargs) + end_time = time.time() + n, high = tracemalloc.get_traced_memory() + tracemalloc.stop() + performance.total_time += end_time - start_time + performance.counter += 1 + performance.total_mem += high + return res + return init diff --git a/Week04/functions_muhammet_taha_parlak.py b/Week04/functions_muhammet_taha_parlak.py new file mode 100644 index 00000000..fb744926 --- /dev/null +++ b/Week04/functions_muhammet_taha_parlak.py @@ -0,0 +1,31 @@ +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 mathematical equation. + + :param x: The first base value. + :param y: The second base value. + :param a: The exponent for x. + :param b: The exponent for y. + :param c: The divisor. + :return: The result of the equation. + """ + + res = float((x ** a + y**b) / c) + return res + +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 + return fn_w_counter.counter, {__name__: fn_w_counter.counter} + + # Çağıran modülün adını al (__main__ gibi) + import inspect + caller_name = inspect.currentframe().f_back.f_globals.get('__name__', 'unknown') + + fn_w_counter.callers[caller_name] = fn_w_counter.callers.get(caller_name, 0) + 1 + + return fn_w_counter.calls, fn_w_counter.callers diff --git a/Week05/awaitme_muhammet_taha_parlak.py b/Week05/awaitme_muhammet_taha_parlak.py new file mode 100644 index 00000000..ebb3e882 --- /dev/null +++ b/Week05/awaitme_muhammet_taha_parlak.py @@ -0,0 +1,5 @@ +def awaitme(func): + async def init(*args,**kwargs): + res = func(*args,**kwargs) + return res + return init