Thursday, January 21, 2021

python day 23 topic classes with super function

 # -*- coding: utf-8 -*-

"""


 day 23:

topic : classes

@author: 



class employee():

    pass



employee()



class employee():

    #print("this is employee class")

    

    def __init__(self,s_no,name,sal):

        self.s_no = s_no

        self.name = name

        self.sal  = sal

        #print("inside constructor",a,b)

        

    def display(self):

        print("employee info ",self.s_no,self.name, self.sal )

        



s=employee(1,"venky",2000)

s.display()



class person():

    def __init__(self,name,):

        self.name=name

        

    def display(self):

        print("employee info ",self.name )

    

class employee(person):   

    

    def __init__(self,name):

        person.__init__(self,name)

        

    


a=employee("ram")

a.display()


"""


class person():

    def __init__(self,name,):

        self.name=name

        

    def display(self):

        print("employee info ",self.name )

    

class employee(person):   

    

    def __init__(self,name):

       super().__init__(name)

        

a=employee("ram")

a.display()


No comments:

Post a Comment

python class topic video