SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
PYTHON-INHERITANCE
What is Inheritance
Inheritance is the ability to ‘inherit’ features or attributes from already
written classes into newer classes we make. These features and
attributes are defined data structures and the functions we can
perform with them, a.k.a. Methods. It promotes code reusability, which
is considered one of the best industrial coding practices as it makes the
codebase modular.
In python inheritance, new class/es inherits from older class/es. The
new class/es copies all the older class's functions and attributes
without rewriting the syntax in the new class/es. These new classes are
called derived classes, and old ones are called base classes.
Types of Inheritance in Python
1. Single Inheritance
2. Multiple Inheritance
3. Multi Level Inheritance
4. Hierarchical Inheritance in Python
5. Hybrid Inheritance in Python
Parent1 -> Child1 : Single Inheritance
Parent1 -> Child1 -> Child2 : Multi – Level Inheritance
Parent1 -> Child2 <- Parent2 : Multiple Inheritance
Single Inheritance in python
Single Inheritance is the simplest form of inheritance where a single
child class is derived from a single parent class. Due to its candid
nature, it is also known as Simple Inheritance.
Single Inheritance Example
Multiple Inheritance in Python
In multiple inheritance, a single child class is inherited from two or
more parent classes. It means the child class has access to all the
parent classes' methods and attributes.
Multiple Inheritance Example
Multilevel Inheritance in Python
In multilevel inheritance, we go beyond just a parent-child relation. We
introduce grandchildren, great-grandchildren, grandparents, etc. We
have seen only two levels of inheritance with a superior parent class/es
and a derived class/es, but here we can have multiple levels where the
parent class/es itself is derived from another class/es.
Example for MultiLevel Inheritance
Hierarchical Inheritance
Hierarchical Inheritance is the right opposite of multiple inheritance. It
means that, there are multiple derived child classes from a single
parent class.
Example for Hierarchical Inheritance
Hybrid Inheritance in Python
Hybrid Inheritance is the mixture of two or more different types of
inheritance. Here we can have many relationships between parent and
child classes with multiple levels.
Example for Hybrid Inheritance
Advantage of Inheritance in Python
Modular Codebase:
Increases modularity, i.e., breaking down codebase into modules, making it easier to understand.
Here, each class we define becomes a separate module that can be inherited separately by one
or many classes.
Code Reusability: the child class copies all the attributes and methods of the parent class into its class
and use. It saves time and coding effort by not rewriting them, thus following modularity paradigms.
Less Development and Maintenance Costs: changes need to be made in the base class; all
derived classes will automatically follow.
Disadvantage of Inheritance in Python
Decreases the Execution Speed: loading multiple classes because they
are interdependent
Tightly Coupled Classes: this means that even though parent classes
can be executed independently, child classes cannot be executed
without defining their parent classes.

More Related Content

PPTX
Polymorphism in Python
PPTX
OOP concepts -in-Python programming language
PPTX
Basics of Object Oriented Programming in Python
PPTX
CLASS OBJECT AND INHERITANCE IN PYTHON
PPTX
Chapter 07 inheritance
PPTX
Python-Classes.pptx
PPTX
Python-DataAbstarction.pptx
PPTX
Python-Encapsulation.pptx
Polymorphism in Python
OOP concepts -in-Python programming language
Basics of Object Oriented Programming in Python
CLASS OBJECT AND INHERITANCE IN PYTHON
Chapter 07 inheritance
Python-Classes.pptx
Python-DataAbstarction.pptx
Python-Encapsulation.pptx

What's hot (20)

PPTX
Python Functions
PPTX
Functions in python
PPTX
Variables in python
PDF
Python programming : Classes objects
PPTX
Functions in Python
PPTX
Python: Polymorphism
PPTX
Functions in python slide share
PDF
Strings in python
PDF
Python libraries
PPTX
Object Oriented Programming in Python
PDF
Datatypes in python
PDF
Python Flow Control
PDF
Arrays in Java
PPSX
Modules and packages in python
PPTX
Chapter 05 classes and objects
PDF
Python list
PPTX
Function in C program
PPTX
Functions in C
PPTX
Python Libraries and Modules
Python Functions
Functions in python
Variables in python
Python programming : Classes objects
Functions in Python
Python: Polymorphism
Functions in python slide share
Strings in python
Python libraries
Object Oriented Programming in Python
Datatypes in python
Python Flow Control
Arrays in Java
Modules and packages in python
Chapter 05 classes and objects
Python list
Function in C program
Functions in C
Python Libraries and Modules
Ad

Similar to Python-Inheritance.pptx (20)

PDF
Inheritance and polymorphism oops concepts in python
PPTX
INHERITANCE ppt of python.pptx & PYTHON INHERITANCE PPT
PPTX
Inheritance in Python Inheritance in Pyt
PPTX
Inheritance Super and MRO _
PDF
Unit_3_2_INHERITANUnit_3_2_INHERITANCE.pdfCE.pdf
PPTX
OOP-part-2 object oriented programming.pptx
PDF
All about python Inheritance.python codingdf
PPT
Topic inheritance
PPTX
arthimetic operator,classes,objects,instant
PDF
Lecture on Python OP concepts of Polymorpysim and Inheritance.pdf
PDF
Python programming : Inheritance and polymorphism
PPTX
Inheritance_in_OOP_using Python Programming
PPTX
Inheritance_Polymorphism_Overloading_overriding.pptx
PPTX
McMullen_ProgwPython_1e_mod17_PowerPoint.pptx
PPT
week 11 inheritance week 11 inheritances
PPT
inheritance in python with full detail.ppt
PDF
Object oriented Programning Lanuagues in text format.
PPTX
Class and Objects in python programming.pptx
PPTX
types of inheritancec , inheritance ,data structures and algorithim oresentat...
PPTX
python1 object oriented programming.pptx
Inheritance and polymorphism oops concepts in python
INHERITANCE ppt of python.pptx & PYTHON INHERITANCE PPT
Inheritance in Python Inheritance in Pyt
Inheritance Super and MRO _
Unit_3_2_INHERITANUnit_3_2_INHERITANCE.pdfCE.pdf
OOP-part-2 object oriented programming.pptx
All about python Inheritance.python codingdf
Topic inheritance
arthimetic operator,classes,objects,instant
Lecture on Python OP concepts of Polymorpysim and Inheritance.pdf
Python programming : Inheritance and polymorphism
Inheritance_in_OOP_using Python Programming
Inheritance_Polymorphism_Overloading_overriding.pptx
McMullen_ProgwPython_1e_mod17_PowerPoint.pptx
week 11 inheritance week 11 inheritances
inheritance in python with full detail.ppt
Object oriented Programning Lanuagues in text format.
Class and Objects in python programming.pptx
types of inheritancec , inheritance ,data structures and algorithim oresentat...
python1 object oriented programming.pptx
Ad

Recently uploaded (20)

PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPT
Project quality management in manufacturing
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
DOCX
573137875-Attendance-Management-System-original
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Well-logging-methods_new................
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
PPT on Performance Review to get promotions
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
UNIT 4 Total Quality Management .pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Structs to JSON How Go Powers REST APIs.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Lesson 3_Tessellation.pptx finite Mathematics
Project quality management in manufacturing
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
bas. eng. economics group 4 presentation 1.pptx
Construction Project Organization Group 2.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
573137875-Attendance-Management-System-original
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Well-logging-methods_new................
CYBER-CRIMES AND SECURITY A guide to understanding
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPT on Performance Review to get promotions
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
UNIT 4 Total Quality Management .pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

Python-Inheritance.pptx

  • 2. What is Inheritance Inheritance is the ability to ‘inherit’ features or attributes from already written classes into newer classes we make. These features and attributes are defined data structures and the functions we can perform with them, a.k.a. Methods. It promotes code reusability, which is considered one of the best industrial coding practices as it makes the codebase modular. In python inheritance, new class/es inherits from older class/es. The new class/es copies all the older class's functions and attributes without rewriting the syntax in the new class/es. These new classes are called derived classes, and old ones are called base classes.
  • 3. Types of Inheritance in Python 1. Single Inheritance 2. Multiple Inheritance 3. Multi Level Inheritance 4. Hierarchical Inheritance in Python 5. Hybrid Inheritance in Python Parent1 -> Child1 : Single Inheritance Parent1 -> Child1 -> Child2 : Multi – Level Inheritance Parent1 -> Child2 <- Parent2 : Multiple Inheritance
  • 4. Single Inheritance in python Single Inheritance is the simplest form of inheritance where a single child class is derived from a single parent class. Due to its candid nature, it is also known as Simple Inheritance.
  • 6. Multiple Inheritance in Python In multiple inheritance, a single child class is inherited from two or more parent classes. It means the child class has access to all the parent classes' methods and attributes.
  • 8. Multilevel Inheritance in Python In multilevel inheritance, we go beyond just a parent-child relation. We introduce grandchildren, great-grandchildren, grandparents, etc. We have seen only two levels of inheritance with a superior parent class/es and a derived class/es, but here we can have multiple levels where the parent class/es itself is derived from another class/es.
  • 10. Hierarchical Inheritance Hierarchical Inheritance is the right opposite of multiple inheritance. It means that, there are multiple derived child classes from a single parent class.
  • 12. Hybrid Inheritance in Python Hybrid Inheritance is the mixture of two or more different types of inheritance. Here we can have many relationships between parent and child classes with multiple levels.
  • 13. Example for Hybrid Inheritance
  • 14. Advantage of Inheritance in Python Modular Codebase: Increases modularity, i.e., breaking down codebase into modules, making it easier to understand. Here, each class we define becomes a separate module that can be inherited separately by one or many classes. Code Reusability: the child class copies all the attributes and methods of the parent class into its class and use. It saves time and coding effort by not rewriting them, thus following modularity paradigms. Less Development and Maintenance Costs: changes need to be made in the base class; all derived classes will automatically follow.
  • 15. Disadvantage of Inheritance in Python Decreases the Execution Speed: loading multiple classes because they are interdependent Tightly Coupled Classes: this means that even though parent classes can be executed independently, child classes cannot be executed without defining their parent classes.