Пример #1
0
    def test_three_operands_result(self):
        from calculator import addition

        operands = "/4/5/-1"
        expected_result = "Sum of operands: 8"
        actual = addition(operands)
        self.assertTrue(expected_result in actual)
Пример #2
0
    def test_three_operands_values(self):
        from calculator import addition

        operands = "/4/5/-1"
        expected_values = "Operands provided: [4, 5, -1]"
        actual = addition(operands)
        self.assertTrue(expected_values in actual)
Пример #3
0
    def test_one_operand_result(self):
        from calculator import addition

        operands = "4"
        expected_result = "4"
        actual = addition(operands)
        self.assertTrue(expected_result in actual)
Пример #4
0
    def test_one_operand_values(self):
        from calculator import addition

        operands = "4"
        expected_values = "Operands provided: [4]"
        actual = addition(operands)
        self.assertTrue(expected_values in actual)
 def test_addition_2(self):
     self.assertEqual(calculator.addition(-2, -3), -5)
Пример #6
0
 def test01(self):
     self.assertEqual(addition(10, 20), 30)
Пример #7
0
    def test03(self):
        self.assertEqual(addition(10.0, "20"), 30.0)
        self.assertEqual(addition("10", "20"), 30.0)

        self.assertEqual(addition("10.0", 20), 30.0)
        self.assertEqual(addition("10.0", "20.0"), 30.0)
Пример #8
0
 def test_three_operands_result(self):
     from calculator import addition
     operands = '/4/5/-1'
     expected_result = "Sum of operands: 8"
     actual = addition(operands)
     self.assertTrue(expected_result in actual)
Пример #9
0
 def test_addition(self):
     self.assertEqual(calculator.addition(2, 1), 3)
     self.assertEqual(calculator.addition(-5, 3), -2)
     self.assertEqual(calculator.addition(-5, 0), -5)
     self.assertEqual(calculator.addition(-5.5, 10), 4.5)
 def test_addition(self):
     self.assertEqual(calculator.addition(1,1),2.0)
     self.assertEqual(calculator.addition(2,3),5.0)
Пример #11
0
 def test_one_operand_result(self):
     from calculator import addition
     operands = "4"
     expected_result = "4"
     actual = addition(operands)
     self.assertTrue(expected_result in actual)
Пример #12
0
 def test_additionNegative(self):
     self.assertAlmostEqual(addition(3.5, -3.5), 0)
Пример #13
0
 def test_addition(self):
     self.assertEqual(addition(3, 3), 6)
 def test_addition_1(self):
     self.assertEqual(calculator.addition(2, 3), 5)
 def test_addition_3(self):
     self.assertEqual(calculator.addition(3.5, 4.5), 8.0)
Пример #16
0
 def testAdd4 (self):
     self.assertEqual(addition('String', 3.5), 'Must be non string input')
Пример #17
0
 def testAdd3 (self):
     self.assertEqual(addition(-12.5, 3.5), -9.0)
Пример #18
0
 def testAdd2 (self):
     self.assertEqual(addition(20, 0), 20.0)
Пример #19
0
 def test_invalidAddition(self):
     self.assertEqual(addition("bad input", 4), None)
Пример #20
0
import calculator
import addition

a = [1, 2, 3, 4, 4, 2, 2, 2, 2]
c = calculator.addition(a)
print(c)
print(a)
print(c, a)
str(a)
print(a)
Пример #21
0
 def test_additionFloat(self):
     self.assertAlmostEqual(addition(3.5, 4.24), 7.74)
import calculator

user_choice = input("What operation do you want to perform: 1 - addition, 2 - subtraction, 3 - multiplication or 4 - division? ")
a = float(input("Enter the value a: "))
b = float(input("Enter the value b: "))

if user_choice == "1":
    print(calculator.addition(a, b))
elif user_choice == "2":
    print(calculator.subtraction(a, b))
elif user_choice == "3":
    print(calculator.multiplication(a, b))
elif user_choice == "4":
    print(calculator.division(a, b))
else:
    print("Incorrect value!")
Пример #23
0
from calculator import addition, subtraction, multipication, division

while True:
    try:
        first = int(input("First Number: "))
        operand = input("Would you like to +, -, * or / ? ")
        second = int(input("Second Number: "))

        if operand == "+":
            addition(first, second)
            break
        elif operand == "-":
            subtraction(first, second)
            break
        elif operand == "*":
            multipication(first, second)
            break
        elif operand == "/":
            division(first, second)
            break
        else:
            print("Please enter a valid operand.")
    except ValueError:
        print("Please enter numbers only!")

quit = input("To quit the program, please press q then hit enter.").lower()
if quit == "q":
    import sys
    sys.exit(0)
 def test_addition(self):
     self.assertEqual(calculator.addition(6, 3), 9.0)
     self.assertEqual(calculator.addition(1, 2), 3.0)
     self.assertEqual(calculator.addition(4, 8), 12.0)
     self.assertEqual(calculator.addition(9, 3), 12.0)
Пример #25
0
 def test_three_operands_values(self):
     from calculator import addition
     operands = '/4/5/-1'
     expected_values = "Operands provided: [4, 5, -1]"
     actual = addition(operands)
     self.assertTrue(expected_values in actual)
Пример #26
0
def test_addition():
    assert calculator.addition(2, 2) == 5
    assert calculator.addition(-1, 2) == 1
    assert calculator.addition(1, -3) == -2
    assert calculator.addition(-1, 1) == 0
Пример #27
0
 def test_no_operand_values(self):
     from calculator import addition
     operands = ""
     expected_values = "Operands provided: []"
     actual = addition(operands)
     self.assertTrue(expected_values in actual)
Пример #28
0
 def test_addition(self):
     result = addition(50, 25)
     self.assertEqual(result, 75)
Пример #29
0
 def test_addition(self):
     assert 4 == calculator.addition(2,2)
Пример #30
0
 def test_1add(self):
     result = calculator.addition(3, 4)
     self.assertEqual(result, 7)
Пример #31
0
 def test02(self):
     self.assertEqual(addition(10, 20.0), 30.0)
     self.assertEqual(addition(10.0, 20), 30.0)
     self.assertEqual(addition(10.0, 20.0), 30.0)
Пример #32
0
 def test_2add(self):
     result = calculator.addition(122, -1)
     self.assertEqual(result, 121)
Пример #33
0
 def test04(self):
     self.assertEqual(addition("10.0", True), 30.0)
Пример #34
0
 def test_addition(self):
     self.assertEqual(self.a + self.b, calculator.addition(self.a, self.b))