You are on page 1of 11

KCIC

KCIC
Creating borderless opportunities
KCIC
KCIC
Creating borderless opportunities
KCIC
KCIC
Creating borderless opportunities
KCIC
KCIC
Creating borderless opportunities
KCIC
KCIC
Creating borderless opportunities
KCIC
KCIC
Creating borderless opportunities
KCIC
KCIC
Creating borderless opportunities
KCIC
KCIC
ACTIVITY:Predict
ACTIVITY: Predictthe
theoutput
outputof
offollowing
followingPython
Pythonprograms
programs

classX(object):
class X(object): # Base or Super class
    def__init__(self,
    def __init__(self,a):
a): class Person(object):
    def __init__(self, name):
        self.num==aa
        self.num         self.name = name
    defdoubleup(self):
    def doubleup(self):     def getName(self):
        return self.name  
        self.num*=
        self.num *=22     def isEmployee(self):
classY(X):
class Y(X):         return False
    def__init__(self,
    def __init__(self,a):
a): # Inherited or Subclass (Note Person in bracket)
class Employee(Person):
        X.__init__(self,a)
        X.__init__(self, a)     def __init__(self, name, eid):
    deftripleup(self):
    def tripleup(self):         ''' In Python 3.0+, "super().__init__(name)"
            also works'''
        self.num*=
        self.num *=33         super(Employee, self).__init__(name)
obj==Y(4)
obj Y(4)         self.empID = eid    
print(obj.num)
print(obj.num)     def isEmployee(self):
        return True 
obj.doubleup()
obj.doubleup()     def getID(self):
print(obj.num)
print(obj.num)         return self.empID
# Driver code
obj.tripleup()
obj.tripleup() emp = Employee("Geek1", "E101")
print(obj.num)
print(obj.num) print(emp.getName(), emp.isEmployee(), emp.getID())

Creating borderless opportunities


KCIC
KCIC
Creating borderless opportunities
KCIC
KCIC
Creating borderless opportunities
KCIC
KCIC
Creating borderless opportunities

You might also like