Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Week03/pyramid_ahmet_burak_guvercin.py
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions Week04/functions_ahmet_burak_guvercin.py
Original file line number Diff line number Diff line change
@@ -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}
9 changes: 9 additions & 0 deletions Week05/awaitme_ahmet_burak_guvercin.py
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions timer_ahmet_burak_guvercin.py
Original file line number Diff line number Diff line change
@@ -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()
Loading