SlideShare a Scribd company logo
3
Most read
5
Most read
7
Most read
CLASS OBJECT
&
INHERITANCE
I N P Y T H O N
CONTENTS
 Class
 Object
 Inheritance
WHAT ARE CLASSES AND OBJECTS IN PYTHON?
Python is an object oriented programming language. Unlike procedure
oriented programming, where the main emphasis is on functions, object
oriented programming stress on objects.
Object is simply a collection of data (variables) and methods (functions) that
act on those data. And, class is a blueprint for the object.
We can think of class as a sketch (prototype) of a house. It contains all the
details about the floors, doors, windows etc. Based on these descriptions we
build the house. House is the object.
As, many houses can be made from a description, we can create many
objects from a class. An object is also called an instance of a class and the
process of creating this object is called instantiation.
DEFINING A CLASS IN PYTHON
Like function definitions begin with the keyword def, in Python, we define a class
using the keyword class.
Here is a simple class definition.
CREATING AN OBJECT IN PYTHON
We saw that the class object could be used to access different attributes.
It can also be used to create new object instances (instantiation) of that class. The
procedure to create an object is similar to a function call.
EXAMPLE
CLASS OBJECT AND INHERITANCE IN PYTHON
WHAT IS INHERITANCE?
Inheritance is a powerful feature in object oriented programming.
It refers to defining a new class with little or no modification to an existing class. The
new class is called derived (or child) class and the one from which it inherits is called
the base (or parent) class.
PYTHON INHERITANCE SYNTAX
TYPES OF INHERITANCE
 Single Inheritance
 Multiple Inheritance
 Multilevel Inheritance
 Hybrid Inheritance
 Hierarchical Inheritance
SINGLE INHERITANCE
 In which there is one base class and one derived class
MULTIPLE INHERITANCE
 Multiple inheritance is possible in python
 A class can be derived from more then one base classes. The syntax for multiple
inheritance is similar to single inheritance
 Here is an example of multiple inheritance
CLASS OBJECT AND INHERITANCE IN PYTHON
MULTILEVEL INHERITANCE
 Multilevel inheritance is also possible in Python like other Object Oriented
programming languages. We can inherit a derived class from another derived class,
this process is known as multilevel inheritance. In Python, multilevel inheritance can
be done at any depth.
CLASS OBJECT AND INHERITANCE IN PYTHON
HYBRID INHERITANCE
CLASS OBJECT AND INHERITANCE IN PYTHON
HIERARCHICAL INHERITANCE
 In which there is single base class and multiple derived class
CLASS OBJECT AND INHERITANCE IN PYTHON
THANK YOU

More Related Content

PPTX
Python-DataAbstarction.pptx
Karudaiyar Ganapathy
 
PPTX
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
PPTX
Loops in Python
AbhayDhupar
 
PPTX
Chapter 14 strings
Praveen M Jigajinni
 
PPTX
Chapter 07 inheritance
Praveen M Jigajinni
 
PPTX
Constructor in java
Pavith Gunasekara
 
PPTX
Public cloud
Dr.Neeraj Kumar Pandey
 
PPTX
Object Oriented Programming in Python
Sujith Kumar
 
Python-DataAbstarction.pptx
Karudaiyar Ganapathy
 
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
Loops in Python
AbhayDhupar
 
Chapter 14 strings
Praveen M Jigajinni
 
Chapter 07 inheritance
Praveen M Jigajinni
 
Constructor in java
Pavith Gunasekara
 
Object Oriented Programming in Python
Sujith Kumar
 

What's hot (20)

PPTX
Chapter 05 classes and objects
Praveen M Jigajinni
 
PPTX
Applets in java
Wani Zahoor
 
PDF
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
PPTX
Abstract Data Types
karthikeyanC40
 
PPTX
Python Functions
Mohammed Sikander
 
PPTX
Conditional and control statement
narmadhakin
 
PPTX
Python-Encapsulation.pptx
Karudaiyar Ganapathy
 
PPTX
Classes objects in java
Madishetty Prathibha
 
PPTX
Strings in Java
Abhilash Nair
 
PPTX
Polymorphism in Python
Home
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPTX
Python OOPs
Binay Kumar Ray
 
PPTX
Java string handling
Salman Khan
 
PPSX
Modules and packages in python
TMARAGATHAM
 
PDF
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
PPTX
Variables in python
Jaya Kumari
 
PPT
Java collections concept
kumar gaurav
 
PPTX
Java package
CS_GDRCST
 
PPTX
JAVA AWT
shanmuga rajan
 
PPTX
Type casting in java
Farooq Baloch
 
Chapter 05 classes and objects
Praveen M Jigajinni
 
Applets in java
Wani Zahoor
 
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
Abstract Data Types
karthikeyanC40
 
Python Functions
Mohammed Sikander
 
Conditional and control statement
narmadhakin
 
Python-Encapsulation.pptx
Karudaiyar Ganapathy
 
Classes objects in java
Madishetty Prathibha
 
Strings in Java
Abhilash Nair
 
Polymorphism in Python
Home
 
07. Virtual Functions
Haresh Jaiswal
 
Python OOPs
Binay Kumar Ray
 
Java string handling
Salman Khan
 
Modules and packages in python
TMARAGATHAM
 
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
Variables in python
Jaya Kumari
 
Java collections concept
kumar gaurav
 
Java package
CS_GDRCST
 
JAVA AWT
shanmuga rajan
 
Type casting in java
Farooq Baloch
 
Ad

Similar to CLASS OBJECT AND INHERITANCE IN PYTHON (20)

PDF
Object And Oriented Programing ( Oop ) Languages
Jessica Deakin
 
PPT
inheritance in python with full detail.ppt
ssuser7b0a4d
 
PPTX
Class and Objects in python programming.pptx
Rajtherock
 
PPTX
Intro to object oriented programming.pptx
RafiaZafar19
 
PPTX
python1 object oriented programming.pptx
PravinBhargav1
 
PPTX
PRESENTATION ON PYTHON.pptx
abhishek364864
 
PPTX
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
PPTX
Python-Classes.pptx
Karudaiyar Ganapathy
 
PPTX
Creating class, self variables in Python
AditiPawaskar5
 
PDF
Python Programming - VIII. Inheritance and Polymorphism
Ranel Padon
 
PPTX
Regex,functions, inheritance,class, attribute,overloding
sangumanikesh
 
PPTX
OOPS 46 slide Python concepts .pptx
mrsam3062
 
PPTX
Object Oriented Programming.pptx
SAICHARANREDDYN
 
DOC
Research paper
hirrahAzhar
 
PPTX
Understanding Python
Kaleem Ullah Mangrio
 
DOCX
Java OOPs Concepts.docx
FredWauyo
 
PDF
Object oriented programming
mustafa sarac
 
PDF
From Java to Python: beating the Stockholm syndrome
Javier Arias Losada
 
PDF
Object-Oriented Programming System presentation
PavanKumarPathipati
 
PDF
oopsinvb-191021101327.pdf
JP Chicano
 
Object And Oriented Programing ( Oop ) Languages
Jessica Deakin
 
inheritance in python with full detail.ppt
ssuser7b0a4d
 
Class and Objects in python programming.pptx
Rajtherock
 
Intro to object oriented programming.pptx
RafiaZafar19
 
python1 object oriented programming.pptx
PravinBhargav1
 
PRESENTATION ON PYTHON.pptx
abhishek364864
 
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
Python-Classes.pptx
Karudaiyar Ganapathy
 
Creating class, self variables in Python
AditiPawaskar5
 
Python Programming - VIII. Inheritance and Polymorphism
Ranel Padon
 
Regex,functions, inheritance,class, attribute,overloding
sangumanikesh
 
OOPS 46 slide Python concepts .pptx
mrsam3062
 
Object Oriented Programming.pptx
SAICHARANREDDYN
 
Research paper
hirrahAzhar
 
Understanding Python
Kaleem Ullah Mangrio
 
Java OOPs Concepts.docx
FredWauyo
 
Object oriented programming
mustafa sarac
 
From Java to Python: beating the Stockholm syndrome
Javier Arias Losada
 
Object-Oriented Programming System presentation
PavanKumarPathipati
 
oopsinvb-191021101327.pdf
JP Chicano
 
Ad

Recently uploaded (20)

PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PPTX
ternal cell structure: leadership, steering
hodeeesite4
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
PDF
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PPTX
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PPTX
unit 3a.pptx material management. Chapter of operational management
atisht0104
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
ternal cell structure: leadership, steering
hodeeesite4
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Information Retrieval and Extraction - Module 7
premSankar19
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
unit 3a.pptx material management. Chapter of operational management
atisht0104
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 

CLASS OBJECT AND INHERITANCE IN PYTHON

  • 3. WHAT ARE CLASSES AND OBJECTS IN PYTHON? Python is an object oriented programming language. Unlike procedure oriented programming, where the main emphasis is on functions, object oriented programming stress on objects. Object is simply a collection of data (variables) and methods (functions) that act on those data. And, class is a blueprint for the object. We can think of class as a sketch (prototype) of a house. It contains all the details about the floors, doors, windows etc. Based on these descriptions we build the house. House is the object. As, many houses can be made from a description, we can create many objects from a class. An object is also called an instance of a class and the process of creating this object is called instantiation.
  • 4. DEFINING A CLASS IN PYTHON Like function definitions begin with the keyword def, in Python, we define a class using the keyword class. Here is a simple class definition.
  • 5. CREATING AN OBJECT IN PYTHON We saw that the class object could be used to access different attributes. It can also be used to create new object instances (instantiation) of that class. The procedure to create an object is similar to a function call.
  • 8. WHAT IS INHERITANCE? Inheritance is a powerful feature in object oriented programming. It refers to defining a new class with little or no modification to an existing class. The new class is called derived (or child) class and the one from which it inherits is called the base (or parent) class.
  • 10. TYPES OF INHERITANCE  Single Inheritance  Multiple Inheritance  Multilevel Inheritance  Hybrid Inheritance  Hierarchical Inheritance
  • 11. SINGLE INHERITANCE  In which there is one base class and one derived class
  • 12. MULTIPLE INHERITANCE  Multiple inheritance is possible in python  A class can be derived from more then one base classes. The syntax for multiple inheritance is similar to single inheritance  Here is an example of multiple inheritance
  • 14. MULTILEVEL INHERITANCE  Multilevel inheritance is also possible in Python like other Object Oriented programming languages. We can inherit a derived class from another derived class, this process is known as multilevel inheritance. In Python, multilevel inheritance can be done at any depth.
  • 18. HIERARCHICAL INHERITANCE  In which there is single base class and multiple derived class