def test_modulus(self): self.assertEqual(calculator.mod(10, 3), 1) self.assertEqual(calculator.mod(3, 10), 3) self.assertEqual(calculator.mod(3, -10), -7)
import calculator as cal x = int(input("Enter a Number")) y = int(input("Enter a Number")) z=cal.add(x, y) q=cal.sub(x,y) w=cal.div(x,y) s=cal.mod(x,y) print(z) print(q) print(w) print(s)
def test_modulus(self): assert 1 == calculator.mod(5, 2)
import calculator add_result = calculator.add(10, 2) sub_result = calculator.sub(10, 2) mul_result = calculator.mul(10, 2) div_result = calculator.div(10, 2) mod_result = calculator.mod(10, 2) print(add_result) #=> 12 print(sub_result) #=> 8 print(mul_result) #=> 20 print(div_result) #=> 5 print(mod_result) #=> 0
import calculator as c a = int(input("Enter the first number")) b = int(input("Enter the second number ")) ch = 0 while ch != 6: print("MENU") print( "1.ADD \n 2.SUBTRACT\n 3.MULTIPLICATON \n 4.DIVISION \n 5.MODULUS \n 6.EXIT" ) ch = int(input("enter your choice")) if (ch == 1): z = c.add(a, b) print(z) elif (ch == 2): z = c.sub(a, b) print(z) elif (ch == 3): z = c.mult(a, b) print(z) elif (ch == 4): z = c.div(a, b) print(z) elif (ch == 5): z = c.mod(a, b) print(z) elif (ch == 6): print("exit") else: print("Invalid Number")
def test_mod(self): assert 1 == calculator.mod(4, 3)
"\nEnter 1.ADD \n 2.SUBTRACT \n 3.MULTIPLY \n 4.DIVISION \n 5.MODULUS \n 6.EXIT\n" )) if (o == 1): a = int(input("\nEnter the first number to be added\n")) b = int(input("\nEnter the second number to be added\n")) c = cal.add(a, b) print("\nThe sum is ", c) elif (o == 2): a = int(input("\nEnter the first number to be subtracted\n")) b = int(input("\nEnter the second number to be subtracted\n")) c = cal.sub(a, b) print("\nThe difference is ", c) elif (o == 3): a = int(input("\nEnter the multiplicant\n")) b = int(input("\nEnter the second number to be multiplier\n")) c = cal.mul(a, b) print("\nThe product is ", c) elif (o == 4): a = int(input("\nEnter the first number to be dividend\n")) b = int(input("\nEnter the second number to be divisior\n")) c = cal.div(a, b) print("\nThe quoitent is ", c) elif (o == 5): a = int(input("\nEnter the first number to be dividend\n")) b = int(input("\nEnter the second number to be divisior\n")) c = cal.mod(a, b) print("\nThe remainder is ", c) elif (o == 6): print("\nExiting\n") else: print("\nYou have enter an invalid number.Try Again\n")