Wednesday, October 11, 2017

calculator in python

class calculator():
def __init__(self,a,b):
self.a=a
self.b=b

def addittion(self):
c=self.a+self.b
print(c)

def subtraction(self):
c=self.a-self.b
print(c)

def divison(self):
c=self.a/self.b
print(c)

def multiplication(self):
c=print(self.a*self.b)
print(c)

x=int(input("enter the number"))
y=int(input("enter the second number"))
a=calculator(x,y)
input=input("enter the process\n")
if(input=="add"):
a.addittion()
elif(input=="sub"):
a.subtraction()
elif(input=="mul"):
a.multiplication()
else:
a.divison()

No comments:

Post a Comment