diff --git a/Week03/sequences_umut_turk.py b/Week03/sequences_umut_turk.py new file mode 100644 index 00000000..c16d0f3e --- /dev/null +++ b/Week03/sequences_umut_turk.py @@ -0,0 +1,24 @@ +def remove_duplicates(argList: list) : + for i in argList: + while argList.count(i) > 1: + argList.remove(i) + return argList +def list_counts(argList: list): + retDict = {} + for i in argList: + if i in retDict: + retDict[i] += 1 + else: + retDict[i] = 1 + return retDict +def reverse_dict(argDict: dict): + retDict = {} + for i,j in argDict.items(): + retDict[j]=i + return retDict + + + + + + diff --git a/Week04/decorators_umut_turk.py b/Week04/decorators_umut_turk.py new file mode 100644 index 00000000..b0407ed9 --- /dev/null +++ b/Week04/decorators_umut_turk.py @@ -0,0 +1,22 @@ +import time +import tracemalloc +def performance(fn): + if not hasattr(performance,"counter"): + setattr(performance,"counter",0) + setattr(performance,"total_time",0) + setattr(performance,"total_mem",0) + def wrapper(*args,**kwargs): + tracemalloc.start() + startT = time.perf_counter() + result = fn(*args,**kwargs) + endT = time.perf_counter() + timeT = endT - startT + n, high = tracemalloc.get_traced_memory() + tracemalloc.stop() + performance.total_time += timeT + performance.counter += 1 + performance.total_mem += high + return result + return wrapper + + diff --git a/Week04/functions_umut_turk.py b/Week04/functions_umut_turk.py new file mode 100644 index 00000000..60f87249 --- /dev/null +++ b/Week04/functions_umut_turk.py @@ -0,0 +1,22 @@ +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: + """ + This function returns the result of an operation based on the specified base and exponent values. + + :param x: First base value + :param y: Second base value + :param a: First exponent value + :param b: Second exponent value + :param c: Divisor value + :return: (x**a + y**b)/c + """ + return ((x**a + y**b)/c) +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter,"count"): + setattr(fn_w_counter,"count",1) + setattr(fn_w_counter,"dict",{(str)(__name__) : fn_w_counter.count} ) + else: + fn_w_counter.count +=1 + fn_w_counter.dict[(__name__)] = fn_w_counter.count + return fn_w_counter.count, fn_w_counter.dict diff --git a/Week05/awaitme_umut_turk.py b/Week05/awaitme_umut_turk.py new file mode 100644 index 00000000..09333990 --- /dev/null +++ b/Week05/awaitme_umut_turk.py @@ -0,0 +1,7 @@ +import asyncio + +def awaitme(fn): + async def wrapper(*args,**kwargs): + result = fn(*args,**kwargs) + return result + return wrapper \ No newline at end of file