Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Tuesday, April 16, 2024

Program to illustrate the concept of inheritance in python.

 Code:


class Person(object):

  

  # Constructor

  def __init__(self, name, id):

    self.name = name

    self.id = id


  # To check if this person is an employee

  def Display(self):

    print(self.name, self.id)


# Driver code

emp = Person("Krishna", 999) # An Object of Person

emp.Display()


Output:



No comments:

Post a Comment