diff --git a/Week01/info_alihan_esentas.py b/Week01/info_alihan_esentas.py new file mode 100644 index 00000000..ccfac61c --- /dev/null +++ b/Week01/info_alihan_esentas.py @@ -0,0 +1,2 @@ +student_id = "220316034" +full_name = "Alihan_esentas" diff --git a/Week02/types_alihan_esentas.py b/Week02/types_alihan_esentas.py new file mode 100644 index 00000000..c70e146c --- /dev/null +++ b/Week02/types_alihan_esentas.py @@ -0,0 +1,4 @@ +my_int = 13 +my_float = 21.3 +my_bool = False +my_complex = 11j diff --git a/Week03/pyramid_alihan_esentas.py b/Week03/pyramid_alihan_esentas.py new file mode 100644 index 00000000..236c1067 --- /dev/null +++ b/Week03/pyramid_alihan_esentas.py @@ -0,0 +1,7 @@ +def calculate_pyramid_height(blockNumber): + height = 0 + + while blockNumber > height: + height += 1 + blockNumber -= height + return height diff --git a/Week04/decorators_alihan_esentas.py b/Week04/decorators_alihan_esentas.py new file mode 100644 index 00000000..3daa62a1 --- /dev/null +++ b/Week04/decorators_alihan_esentas.py @@ -0,0 +1,20 @@ +import tracemalloc +import time + +def performance(func): + performance.counter = 0 + performance.total_time = 0.0 + performance.total_mem = 0.0 + + def wrapper(*args, **kwargs): + tracemalloc.start() + start_time = time.time() + result = func(*args, **kwargs) + end_time = time.time() + current, peak = tracemalloc.get_traced_memory() + tracemalloc.stop() + performance.counter += 1 + performance.total_time += (end_time - start_time) + performance.total_mem += peak + return result + return wrapper diff --git a/Week05/awaitme_alihan_esentas.py b/Week05/awaitme_alihan_esentas.py new file mode 100644 index 00000000..0c828f4f --- /dev/null +++ b/Week05/awaitme_alihan_esentas.py @@ -0,0 +1,17 @@ +import asyncio + +def awaitme(fn): + if asyncio.iscoroutinefunction(fn): + return fn + + async def wrapper(*args, **kwargs): + return fn(*args, **kwargs) + + try: + wrapper.__name__ = fn.__name__ + wrapper.__doc__ = fn.__doc__ + wrapper.__annotations__ = fn.__annotations__ + except (AttributeError, TypeError): + pass + + return wrapper