diff --git a/Week03/pyramid_ahmet_burak_guvercin.py b/Week03/pyramid_ahmet_burak_guvercin.py new file mode 100644 index 00000000..46ef08fd --- /dev/null +++ b/Week03/pyramid_ahmet_burak_guvercin.py @@ -0,0 +1,10 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + blocks_needed = 1 + + while number_of_blocks >= blocks_needed: + number_of_blocks -= blocks_needed + height += 1 + blocks_needed += 1 + + return height diff --git a/Week04/functions_ahmet_burak_guvercin.py b/Week04/functions_ahmet_burak_guvercin.py new file mode 100644 index 00000000..bb0db79c --- /dev/null +++ b/Week04/functions_ahmet_burak_guvercin.py @@ -0,0 +1,30 @@ +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. + :type x: int + :param y: The second base value. + :type y: int + :param a: The exponent for x. + :type a: int + :param b: The exponent for y. + :type b: int + :param c: The divisor. + :type c: int + :return: The result of the equation. + :rtype: float + """ + return (x**a + y**b) / c + +def fn_w_counter() -> (int, dict[str, int]): + if not hasattr(fn_w_counter, "count"): + fn_w_counter.count = 0 + + fn_w_counter.count += 1 + + module_name = __name__.split('.')[-1] + + return fn_w_counter.count, {module_name: fn_w_counter.count} diff --git a/Week05/awaitme_ahmet_burak_guvercin.py b/Week05/awaitme_ahmet_burak_guvercin.py new file mode 100644 index 00000000..7f7f7c53 --- /dev/null +++ b/Week05/awaitme_ahmet_burak_guvercin.py @@ -0,0 +1,9 @@ +import asyncio + +def awaitme(function): + async def wrapper(*args, **kwargs): + result = function(*args, **kwargs) + if asyncio.iscoroutine(result): + return await result + return result + return wrapper diff --git a/timer_ahmet_burak_guvercin.py b/timer_ahmet_burak_guvercin.py new file mode 100644 index 00000000..ac427b69 --- /dev/null +++ b/timer_ahmet_burak_guvercin.py @@ -0,0 +1,13 @@ +import time + +class Timer: + def __init__(self): + self.start_time = None + self.end_time = None + + def __enter__(self): + self.start_time = time.time() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.end_time = time.time()