#Defining Class to total of two variables
class total:
def setvar(self,x,y): #defining member functions to get variable from user
self.x = int (input("enter value of x :->"))
self.y = int (input("enter value of y :->"))
def addvar(self): #defining member functions to add variables
z=int(self.x+self.y)
print(z)
sum=total()# create class instance
sum.setvar("x","y")
sum.addvar()
No comments:
Post a Comment