Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 6
0
 def test01(self):
     self.assertEqual(addition(10, 20), 30)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 12
0
 def test_additionNegative(self):
     self.assertAlmostEqual(addition(3.5, -3.5), 0)
Ejemplo n.º 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)
Ejemplo n.º 16
0
 def testAdd4 (self):
     self.assertEqual(addition('String', 3.5), 'Must be non string input')
Ejemplo n.º 17
0
 def testAdd3 (self):
     self.assertEqual(addition(-12.5, 3.5), -9.0)
Ejemplo n.º 18
0
 def testAdd2 (self):
     self.assertEqual(addition(20, 0), 20.0)
Ejemplo n.º 19
0
 def test_invalidAddition(self):
     self.assertEqual(addition("bad input", 4), None)
Ejemplo n.º 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)
Ejemplo n.º 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!")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 28
0
 def test_addition(self):
     result = addition(50, 25)
     self.assertEqual(result, 75)
Ejemplo n.º 29
0
 def test_addition(self):
     assert 4 == calculator.addition(2,2)
Ejemplo n.º 30
0
 def test_1add(self):
     result = calculator.addition(3, 4)
     self.assertEqual(result, 7)
Ejemplo n.º 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)
Ejemplo n.º 32
0
 def test_2add(self):
     result = calculator.addition(122, -1)
     self.assertEqual(result, 121)
Ejemplo n.º 33
0
 def test04(self):
     self.assertEqual(addition("10.0", True), 30.0)
Ejemplo n.º 34
0
 def test_addition(self):
     self.assertEqual(self.a + self.b, calculator.addition(self.a, self.b))