diff --git a/src/utils.py b/src/utils.py index faae9e3..12cdcae 100644 --- a/src/utils.py +++ b/src/utils.py @@ -41,7 +41,11 @@ def divide(a: float, b: float) -> float: Returns: float ''' - return a / b + + if b!=0: + return a / b + else: + print("b shouldn't be zero") def modulo(a: int, b: int): ''' @@ -91,7 +95,8 @@ def return_hexadecimal(a: int) -> float: return hex(a) -def return_random_number() -> int: +def return_random_number(a: int, b:int, seed:int) -> int: + ''' ... @@ -103,4 +108,5 @@ def return_random_number() -> int: float ''' - return np.random.randint(0, 100) \ No newline at end of file + np.random.seed(seed) + return np.random.randint(a, b) diff --git a/tests/Test_return_random_number.py b/tests/Test_return_random_number.py new file mode 100644 index 0000000..b6ac062 --- /dev/null +++ b/tests/Test_return_random_number.py @@ -0,0 +1,7 @@ +from src.utils import return_random_number + +try: + return_random_number(0,200, 45) + print("The return_random_number function works") +except: + print("We have an issue with return_random_number function") diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..fb01633 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +from utils import sum, multiply, divide \ No newline at end of file diff --git a/tests/test_hexadecimal.py b/tests/test_hexadecimal.py new file mode 100644 index 0000000..ace9728 --- /dev/null +++ b/tests/test_hexadecimal.py @@ -0,0 +1,6 @@ +from src.utils import return_hexadecimal +def test_hexadecimal(): + a = 2 + b = 3 + + assert return_hexadecimal(a) == hex(a)