diff --git a/Create decorators_veli_unusdu.py b/Create decorators_veli_unusdu.py new file mode 100644 index 00000000..6a158725 --- /dev/null +++ b/Create decorators_veli_unusdu.py @@ -0,0 +1,10 @@ +def calculate_pyramid_height(number_of_blocks): + height = 0 + block_needed = 1 + while number_of_blocks >= block_needed: + height += 1 + number_of_blocks -= block_needed + block_needed += 1 + return height + + diff --git a/Week03/test_pyramid.py b/Week03/test_pyramid.py deleted file mode 100644 index 2c8c6f25..00000000 --- a/Week03/test_pyramid.py +++ /dev/null @@ -1,52 +0,0 @@ -import os - - -files = [f for f in os.listdir(os.path.dirname(__file__)) if f.startswith("pyramid")] -for f in files: - exec("import " + f[:-3] + " as " + f[:-3]) - print(f"The module {f[:-3]} has been imported.") - - -def test_names(): - for f in files: - assert "calculate_pyramid_height" in dir(eval(f[:-3])), ( - "calculate_pyramid_height is not defined in " + f[:-3] - ) - - -def test_types(): - for f in files: - assert callable(eval(f[:-3]).calculate_pyramid_height), ( - "calculate_pyramid_height is not callable in " + f[:-3] - ) - assert isinstance(eval(f[:-3]).calculate_pyramid_height(1), int), ( - "calculate_pyramid_height is not returning an int in " + f[:-3] - ) - - -def test_calculate_pyramid_height(): - for f in files: - assert eval(f[:-3]).calculate_pyramid_height(1) == 1, ( - "calculate_pyramid_height is not working in " + f[:-3] - ) - assert eval(f[:-3]).calculate_pyramid_height(2) == 1, ( - "calculate_pyramid_height is not working in " + f[:-3] - ) - assert eval(f[:-3]).calculate_pyramid_height(6) == 3, ( - "calculate_pyramid_height is not working in " + f[:-3] - ) - assert eval(f[:-3]).calculate_pyramid_height(20) == 5, ( - "calculate_pyramid_height is not working in " + f[:-3] - ) - assert eval(f[:-3]).calculate_pyramid_height(100) == 13, ( - "calculate_pyramid_height is not working in " + f[:-3] - ) - assert eval(f[:-3]).calculate_pyramid_height(1000) == 44, ( - "calculate_pyramid_height is not working in " + f[:-3] - ) - assert eval(f[:-3]).calculate_pyramid_height(10000) == 140, ( - "calculate_pyramid_height is not working in " + f[:-3] - ) - assert eval(f[:-3]).calculate_pyramid_height(100000) == 446, ( - "calculate_pyramid_height is not working in " + f[:-3] - )