コード例 #1
0
def prob3(a,b):
    """Calculate and return the length of the hypotenuse of a right triangle.
    Do not use any methods other than those that are imported from your
    'calculator' module.

    Parameters:
        a (float): the length one of the sides of the triangle.
        b (float): the length the other nonhypotenuse side of the triangle.

    Returns:
        The length of the triangle's hypotenuse.
    """
    return calc.sqrt(calc.add(calc.multiply(a,a), calc.multiply(b,b)))
コード例 #2
0
 def test_sqrt_of_zero_is_zero():
     assert calculator.sqrt(0) == 0
コード例 #3
0
 def test_square_root_with_negative_gives_none():
     assert calculator.sqrt(-5) == None
コード例 #4
0
 def test_square_root_with_positive():
     assert calculator.sqrt(81) == 9
コード例 #5
0
def test_sqrt_exercise_4():
    assert sqrt(25) == 5
コード例 #6
0
def test_sqrt_exercise_6(x, x2):
    assert sqrt(x) == x2
コード例 #7
0
def problem2_3(a,b):
    return c.sqrt(c.add(c.mult(a,a),c.mult(b,b)))
コード例 #8
0
def test_sqrt():
    results = sqrt(9)
    assert results == 3

    results = sqrt(16)
    assert results == 4
コード例 #9
0
 def test_sqrt(self):
     assert 4 == calculator.sqrt(16)