示例#1
0
def test_squareroot():
    input = 25
    result = sqrt(25)
    expected = 5
    assert result == expected
示例#2
0
def test_squarerootspecial():
    with pytest.raises(TypeError):
        result = sqrt(json_string['squareroot'][2]['input'])
        expected = json_string['squareroot'][2]['output']
示例#3
0
def test_squarerootinteger():
    result = sqrt(json_string['squareroot'][3]['input'])
    expected = json_string['squareroot'][3]['output']
示例#4
0
"""

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)