Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Resolve GH-69
Browse files Browse the repository at this point in the history
Move find square function to "calc" package.
Test cases has been adjusted as well.
  • Loading branch information
shorodilov committed Nov 27, 2023
1 parent e52f982 commit 55bd150
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 54 deletions.
Empty file removed src/FindSquare/__init__.py
Empty file.
39 changes: 0 additions & 39 deletions src/FindSquare/square.py

This file was deleted.

1 change: 1 addition & 0 deletions src/calc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"get_fibonacci_number",
"get_fibonacci_number_nr",
"get_sum_of_strings",
"get_square",
"get_squares",
]

Expand Down
19 changes: 17 additions & 2 deletions src/calc/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@
"""

from typing import List
from typing import List, Union


def get_square(number: Union[int, float]) -> Union[int, float]:
"""
Calculate the square value of a given number
:param number: The input number for which the square value is calculated.
:type number: int | float
:return: the square value of the input number
:rtype: int | float
"""

return number ** 2


def get_squares(limit: int, /) -> List[int]:
Expand All @@ -18,7 +33,7 @@ def get_squares(limit: int, /) -> List[int]:
"""

return [number ** 2 for number in range(limit)]
return [get_square(number) for number in range(limit)]


def get_factorial(number: int, /) -> int:
Expand Down
13 changes: 0 additions & 13 deletions tests/FindSquare/test_square.py

This file was deleted.

5 changes: 5 additions & 0 deletions tests/calc/func_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import calc


def test_get_square():
assert calc.get_square(4) == 16
assert calc.get_square(-3) == 9


def test_get_squares():
test = [
0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256
Expand Down

0 comments on commit 55bd150

Please sign in to comment.