diff --git a/Week01/info_batuhan_tunc.py b/Week01/info_batuhan_tunc.py new file mode 100644 index 00000000..60b3fdaf --- /dev/null +++ b/Week01/info_batuhan_tunc.py @@ -0,0 +1,2 @@ +student_id = "240315001" +full_name = "Batuhan Tunc" diff --git a/Week02/types_batuhan_tunc b/Week02/types_batuhan_tunc new file mode 100644 index 00000000..4d572a94 --- /dev/null +++ b/Week02/types_batuhan_tunc @@ -0,0 +1,4 @@ +my_int = 10 +my_float = 10.5 +my_bool = True +my_complex = 1 + 2j diff --git a/Week03/pyramid_batuhan_tunc.py b/Week03/pyramid_batuhan_tunc.py new file mode 100644 index 00000000..cc0e189c --- /dev/null +++ b/Week03/pyramid_batuhan_tunc.py @@ -0,0 +1,8 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + needed = 1 + while number_of_blocks >= needed: + number_of_blocks -= needed + height += 1 + needed += 1 + return height diff --git a/Week03/sequences_batuhan_tunc.py b/Week03/sequences_batuhan_tunc.py new file mode 100644 index 00000000..9ab31292 --- /dev/null +++ b/Week03/sequences_batuhan_tunc.py @@ -0,0 +1,13 @@ +def remove_duplicates(seq:list) -> list: + return list(set(seq)) + + +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()} diff --git a/Week04/decorators_batuhan_tunc.py b/Week04/decorators_batuhan_tunc.py new file mode 100644 index 00000000..3ac9f3fa --- /dev/null +++ b/Week04/decorators_batuhan_tunc.py @@ -0,0 +1,31 @@ +import time +import tracemalloc + +def performance(func): + if not hasattr(performance, 'counter'): + performance.counter = 0 + performance.total_time = 0.0 + performance.total_mem = 0.0 + def wrapper(*args, **kwargs): + # 1. Ölçümleri Başlat + tracemalloc.start() + start_time = time.perf_counter() + + # 2. Asıl Fonksiyonu Çalıştır + result = func(*args, **kwargs) + + # 3. Ölçümleri Bitir + end_time = time.perf_counter() + current_mem, peak_mem = tracemalloc.get_traced_memory() + tracemalloc.stop() + + # 4. İstatistikleri Güncelle + performance.counter += 1 + performance.total_time += (end_time - start_time) + performance.total_mem += peak_mem + + return result + wrapper.__name__ = func.__name__ + wrapper.__doc__ = func.__doc__ + + return wrapper diff --git a/Week04/functions_batuhan_tunc.py b/Week04/functions_batuhan_tunc.py new file mode 100644 index 00000000..4b18359d --- /dev/null +++ b/Week04/functions_batuhan_tunc.py @@ -0,0 +1,24 @@ +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} + diff --git a/Week05/awaitme_batuhan_tunc.py b/Week05/awaitme_batuhan_tunc.py new file mode 100644 index 00000000..06485d25 --- /dev/null +++ b/Week05/awaitme_batuhan_tunc.py @@ -0,0 +1,5 @@ +def awaitme(func): + async def init(*args,**kwargs): + result = func(*args,**kwargs) + return result + return init