def test_squareroot(): input = 25 result = sqrt(25) expected = 5 assert result == expected
def test_squarerootspecial(): with pytest.raises(TypeError): result = sqrt(json_string['squareroot'][2]['input']) expected = json_string['squareroot'][2]['output']
def test_squarerootinteger(): result = sqrt(json_string['squareroot'][3]['input']) expected = json_string['squareroot'][3]['output']
""" Name : SquareRoot.py Date : 26/08/2019 Purpose : compute the square root of a nonnegative number c given in the input using Newton's method: """ from Utility import utility while True: try: #Getting the number from the user c = int(input("Enter a non-negative number : ")) if (c < 0): print("Enter Positive Integers only") continue break except ValueError: print("Enter integers only") continue #Calling the function in the BL file t = utility.sqrt(c) #printing the square root of the number print("Square root is : ", t)