INHERITANCE in python

1.   Inheritance allows us to define a class that inherits all the methods and properties from the          another class

2.  The “pass” keyword is used for Inheritance in python

3.  It’s a core concept of object oriented programming system in python

4.  They are different types of Inheritance in python

* single Inheritance

* multiple Inheritance

* hierarchical Inheritance

* hybrid Inheritance

Syntax of Inheritance

 

Class parent class:
  {Body}
Class child class(parent class):
   Pass

Example program

Class Animal:
 Def eat(self):
   Print('it eats.')
 Def sleep(self):
   Print ('it sleeps.')
Class Brid(Animal):
   Def fly(self):
      Print('it flies in the sky.')
   Def sing(self):
      Print('it sings')
Output 
It eats
It sleeps 
It flies in the sky 
It sings

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top