Ejemplo n.º 1
0
 def test_2(self):
     """check that multiplication is working"""
     self.assertEqual(multiplication(3, 4), 12)
from sub import subtraction
from add import addition

print("Omar helped a girl")

while(True):

    num1=input("Enter the first number:")
    num2=input("Enter the second number:")

    num1=float(num1)
    num2=float(num2)

    op=input("Enter your operation:")

    mulobj=multiplication(num1,num2)
    subobj=subtraction(num1,num2)
    addobj=addition(num1,num2)
    divobj=divition(num1,num2)

    if (op == '*'):
        result=mulobj.mulfunction()
        print("your result is :",result)
    elif (op == '-'):
        result=subobj.subfunction()
        print("Subtraction is:", result)
    elif(op == '+'):
        result=addobj.addfunction()
        print("Addition is:", result)
    elif(op == '/'):
        result=divobj.divfunction()
class subtract(object):
    def __init__(self,a,b):
        self.a=a
        self.b=b
    def sub(self):
        print("The subtraction value is:",self.a-self.b)

MUL.PY PYTHON FILE:

class multiplication(object):
    def __init__(self,a,b):
        self.a=a
        self.b=b
    def mul(self):
        return "The multiplication value is:",self.a*self.b

BASE.PY PYTHON FILE:

from add import addition
from sub import subtract
from mul import multiplication

obj=addition(5,4)
obj_two=subtract(8,2)
obj_three=multiplication(2,9)
obj.add()
obj_two.sub()
print(obj_three.mul())

(NOTE: CREATE __INIT__.PY PYTHON FILE TO CONVERT IT INTO PACKAGES)
Ejemplo n.º 4
0
from mul import multiplication
from sub import sub
from add import add
n1 = 8
n2 = 10
print("Addition result of 8 and 10")
print(add(n1, n2))
print("Multiply result of 8 and 10")
print(multiplication(n1, n2))
print("Substraction result of 8 and 10")
print(sub(n1, n2))

#Implemented Driver function defination
Ejemplo n.º 5
0
import add
import divide
import mul
import sub
import sys

input_1 = int(sys.argv[1])
input_2 = int(sys.argv[2])

print("1: Addition\n 2: Subtraction \n3: Multiply \n4: Divide")

process = int(sys.argv[3])

if process == 1:
    add.addition(input_1, input_2)
elif process == 2:
    sub.sub(input_1, input_2)
elif process == 3:
    mul.multiplication(input_1, input_2)
elif process == 4:
    divide.divide(input_1, input_2)
else:
    print("Please select between 1 to 4 only")