SlideShare a Scribd company logo
3
Most read
11
Most read
12
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

What's hot (20)

PPTX
Data Structures in Python
Devashish Kumar
 
PPTX
Basics of Object Oriented Programming in Python
Sujith Kumar
 
PDF
Python libraries
Prof. Dr. K. Adisesha
 
PPTX
JAVA AWT
shanmuga rajan
 
PPTX
Datastructures in python
hydpy
 
PDF
Python Programming - VI. Classes and Objects
Ranel Padon
 
PPTX
Class, object and inheritance in python
Santosh Verma
 
PPTX
Chapter 07 inheritance
Praveen M Jigajinni
 
PPTX
Functions in python slide share
Devashish Kumar
 
PDF
Python Flow Control
Mohammed Sikander
 
PPT
C by balaguruswami - e.balagurusamy
Srichandan Sobhanayak
 
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
PDF
Arrays In Python | Python Array Operations | Edureka
Edureka!
 
PDF
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Edureka!
 
PPTX
Regular expressions in Python
Sujith Kumar
 
PDF
Python list
Mohammed Sikander
 
PPTX
Python: Modules and Packages
Damian T. Gordon
 
PPTX
Chapter 03 python libraries
Praveen M Jigajinni
 
PDF
Operators in python
Prabhakaran V M
 
PPTX
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
Data Structures in Python
Devashish Kumar
 
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Python libraries
Prof. Dr. K. Adisesha
 
JAVA AWT
shanmuga rajan
 
Datastructures in python
hydpy
 
Python Programming - VI. Classes and Objects
Ranel Padon
 
Class, object and inheritance in python
Santosh Verma
 
Chapter 07 inheritance
Praveen M Jigajinni
 
Functions in python slide share
Devashish Kumar
 
Python Flow Control
Mohammed Sikander
 
C by balaguruswami - e.balagurusamy
Srichandan Sobhanayak
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Arrays In Python | Python Array Operations | Edureka
Edureka!
 
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Edureka!
 
Regular expressions in Python
Sujith Kumar
 
Python list
Mohammed Sikander
 
Python: Modules and Packages
Damian T. Gordon
 
Chapter 03 python libraries
Praveen M Jigajinni
 
Operators in python
Prabhakaran V M
 
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 

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
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
 
PPTX
Oops in vb
Dalwin INDIA
 
Object And Oriented Programing ( Oop ) Languages
Jessica Deakin
 
inheritance in python with full detail.ppt
ssuser7b0a4d
 
Class and Objects in python programming.pptx
Rajtherock
 
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
 
Oops in vb
Dalwin INDIA
 
Ad

Recently uploaded (20)

PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Ad

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