def test_subtraction(self): self.assertEqual(calc.subtraction(3, 1), 2) self.assertEqual(calc.subtraction(3, 4), -1) self.assertEqual(calc.subtraction(1, 0), 1)
def test_subtraction(self): result = calc.subtraction(4,3) self.assertEqual(result, 1)
def test_sub(self): self.assertEqual(calc.subtraction(10, 5), 5) self.assertEqual(calc.subtraction(-1, 1), -2) self.assertEqual(calc.subtraction(-1, -1), 0)
def test_subtraction(self): tests = [(0, 0, 0), (1, 2, -1), (100, 20, 80)] self.assertTrue(all([calc.subtraction(x, y) == a for x,y,a in tests]))
def sub(): sub = subtraction(8,10) return sub
def test_subtraction(self): self.assertEqual(calc.subtraction(10, 5), 5) self.assertEqual(calc.subtraction(10, -10), 20) self.assertEqual(calc.subtraction(-10, -10), 0)
print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") print("5.Power") # Take input from the user choice = input("Enter choice(1/2/3/4/5):") num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) if choice == '1': print(num1, "+", num2, " = ", addition(num1, num2)) elif choice == '2': print(num1, "-", num2, " = ", subtraction(num1, num2)) elif choice == '3': print(num1, "*", num2, " = ", multiplication(num1, num2)) elif choice == '4': print(num1, "/", num2, " = ", division(num1, num2)) elif choice == '5': print(num1, "^", num2, " = ", power(num1, num2)) ############### The Exercises (7- 9) and Warm up exercises (7 & 8) are in the Numpy_Exercise.py file ################## # Ex 10 # Write a python program to read a specific line from a text file. The user enter the specific line,
def test_subtraction(self): self.assertEqual(calc.subtraction(15, 5), 10) self.assertEqual(calc.subtraction(-1, 2), -3) self.assertEqual(calc.subtraction(-1, -1), 0)