示例#1
0
    def test_sum_multiple_various(self):
        x_y_returns = (
            (10, 10, 20),
            (1.5, 3.1, 4.6),
            (-5, 10, 5),
            (10, -10, 0),
        )

        for x_y_return in x_y_returns:
            with self.subTest(x_y_return=x_y_return):
                x, y, returnn = x_y_return
                self.assertEqual(sum(x, y), returnn)
示例#2
0
def hypot(a, b):
    """Calculate and return the length of the hypotenuse of a right triangle.
    Do not use any functions other than those that are imported from your
    'calculator' module.

    Parameters:
        a: the length one of the sides of the triangle.
        b: the length the other non-hypotenuse side of the triangle.
    Returns:
        The length of the triangle's hypotenuse.
    """
    return calc.math.sqrt(calc.sum(calc.product(a, a), calc.product(b, b)))
    raise NotImplementedError("Problem 3 Incomplete")
示例#3
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 the
    '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.
    """
    import calculator

    leg_1 = calculator.product(a,a)
    leg_2 = calculator.product(b,b)
    sum_squared = calculator.sum(leg_1,leg_2)
    hypotenuse = calculator.square_root(sum_squared)
    return hypotenuse
 def test_050_sums_empty_array(self):
     self.assertEqual(sum([]), 0)
示例#5
0
 def test_sum(self):
     self.assertEqual(calculator.sum(3,5),8)
def average(lis):
    average = calculator.sum(lis) / len(lis)
    return average
 def sum(self, m, n):
     return calculator.sum(m, n)
示例#8
0
#Our main application
#First of all input values from the terminal
#Ask user how many numbers to input - 4, 5
#Next ask for n numbers and store them in the list
import calculator
from more_calc import average, PI  #from import
import math
how_many = int(input("How many numbers are you goin to input : "))
numbers = []
for i in range(1, how_many + 1):
    num = int(input("Enter the number : "))
    numbers.append(num)
print(numbers)
print(calculator.sum(numbers))
print(average(numbers))
print(PI)
print(math.sin(0.5))
print(math.cos(-0.5))
def sum(a, b):
    return jsonify({'result': calculator.sum(a, b)})
示例#10
0
 def test_add_integers_negative(self):
     result = c.sum(-1, -2)
     self.assertEqual(result, -3)
示例#11
0
 def test_sum(self):
     self.assertEqual(sum(), 0)
     self.assertEqual(sum(7), 7)
     self.assertEqual(sum(7,11), 18)
     self.assertEqual(sum(1,3,5,7,9), 25)