Skip to content
2 changes: 2 additions & 0 deletions Week01/info_batuhan_tunc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
student_id = "240315001"
full_name = "Batuhan Tunc"
4 changes: 4 additions & 0 deletions Week02/types_batuhan_tunc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
my_int = 10
my_float = 10.5
my_bool = True
my_complex = 1 + 2j
8 changes: 8 additions & 0 deletions Week03/pyramid_batuhan_tunc.py
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions Week03/sequences_batuhan_tunc.py
Original file line number Diff line number Diff line change
@@ -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()}
31 changes: 31 additions & 0 deletions Week04/decorators_batuhan_tunc.py
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions Week04/functions_batuhan_tunc.py
Original file line number Diff line number Diff line change
@@ -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}

5 changes: 5 additions & 0 deletions Week05/awaitme_batuhan_tunc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def awaitme(func):
async def init(*args,**kwargs):
result = func(*args,**kwargs)
return result
return init