0% found this document useful (0 votes)
22 views10 pages

Class - Inheritance: Editedit Mastermaster Texttext Stylesstyles

Inheritance allows classes to inherit properties from other classes. There are benefits like representing real-world relationships, code reusability without rewriting code, and adding features without modifying classes. Python uses the syntax Class DerivedClass(BaseClass) to define inheritance, where the derived class inherits from the base class. There are four types of inheritance in Python: single, multiple, multilevel, and hierarchical inheritance.

Uploaded by

Abhishek Sunil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views10 pages

Class - Inheritance: Editedit Mastermaster Texttext Stylesstyles

Inheritance allows classes to inherit properties from other classes. There are benefits like representing real-world relationships, code reusability without rewriting code, and adding features without modifying classes. Python uses the syntax Class DerivedClass(BaseClass) to define inheritance, where the derived class inherits from the base class. There are four types of inheritance in Python: single, multiple, multilevel, and hierarchical inheritance.

Uploaded by

Abhishek Sunil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Class - Inheritance

EditEdit
MasterMaster
texttext stylesstyles
Inheritance

Inheritance is the capability of one class to derive or inherit the


properties from another class.
Inheritance

Benefits of inheritance are:


● It represents real-world relationships well.
● It provides the reusability of a code. We don’t have to write
the same code again and again. Also, it allows us to add more
features to a class without modifying it.
● It is transitive in nature, which means that if class B inherits
from another class A, then all the subclasses of B would
automatically inherit from class A.
Inheritance

Python Inheritance Syntax :


Class BaseClass:

{Body}

Class DerivedClass(BaseClass):

{Body}
Types of Inheritance in Python
Types of Inheritance depend upon the number of child and parent classes
involved. There are four types of inheritance in Python:

Single Inheritance

Multiple Inheritance

Multilevel Inheritance

Hierarchical Inheritance
Practice question
Single Inheritance:

Single inheritance enables a derived class to inherit properties from a single


parent class, thus enabling code reusability and the addition of new features
to existing code.
Practice question
Multiple Inheritance:

When a class can be derived from more than one base class this type of
inheritance is called multiple inheritances. In multiple inheritances, all the
features of the base classes are inherited into the derived class.
Practice question
Multilevel Inheritance :

In multilevel inheritance, features of the base class and the derived class are
further inherited into the new derived class. This is similar to a relationship
representing a child and a grandfather.
Practice question
Hierarchical Inheritance:

When more than one derived class are created from a single base this type
of inheritance is called hierarchical inheritance. In this program, we have a
parent (base) class and two child (derived) classes.
#LifeKoKaroLift

Thank you!

You might also like