SlideShare a Scribd company logo
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.
Most read
11
SINGLE INHERITANCE
 In which there is one base class and one derived class
Most read
19
CLASS OBJECT AND INHERITANCE IN PYTHON
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)

Python OOPs
Python OOPs
Binay Kumar Ray
 
Chapter 07 inheritance
Chapter 07 inheritance
Praveen M Jigajinni
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Python-Classes.pptx
Python-Classes.pptx
Karudaiyar Ganapathy
 
Python programming : Classes objects
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
Python exception handling
Python exception handling
Mohammed Sikander
 
Class, object and inheritance in python
Class, object and inheritance in python
Santosh Verma
 
Introduction to Python
Introduction to Python
Mohammed Sikander
 
Data Structures in Python
Data Structures in Python
Devashish Kumar
 
Python Functions
Python Functions
Mohammed Sikander
 
Python-Encapsulation.pptx
Python-Encapsulation.pptx
Karudaiyar Ganapathy
 
Modules in Python Programming
Modules in Python Programming
sambitmandal
 
Introduction to Java -unit-1
Introduction to Java -unit-1
RubaNagarajan
 
Functions in Python
Functions in Python
Kamal Acharya
 
NUMPY
NUMPY
Global Academy of Technology
 
Python : Data Types
Python : Data Types
Emertxe Information Technologies Pvt Ltd
 
Introduction to matplotlib
Introduction to matplotlib
Piyush rai
 
Functions in python
Functions in python
colorsof
 
Python Pandas
Python Pandas
Sunil OS
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming language
SmritiSharma901052
 

Similar to CLASS OBJECT AND INHERITANCE IN PYTHON (20)

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

Recently uploaded (20)

362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Call For Papers - International Journal on Natural Language Computing (IJNLC)
Call For Papers - International Journal on Natural Language Computing (IJNLC)
kevig
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
The first edition of the AIAG-VDA FMEA.pptx
The first edition of the AIAG-VDA FMEA.pptx
Mayank Mathur
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
 
Computer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdf
kumarprem6767merp
 
Presentación Tomografía Axial Computarizada
Presentación Tomografía Axial Computarizada
Juliana Ovalle Jiménez
 
Webinar On Steel Melting IIF of steel for rdso
Webinar On Steel Melting IIF of steel for rdso
KapilParyani3
 
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
ijscai
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Class-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdf
takisvlastos
 
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
ijccmsjournal
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
International Journal of Advance Robotics & Expert Systems (JARES)
International Journal of Advance Robotics & Expert Systems (JARES)
jaresjournal868
 
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
gerogepatton
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Call For Papers - International Journal on Natural Language Computing (IJNLC)
Call For Papers - International Journal on Natural Language Computing (IJNLC)
kevig
 
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Rigor, ethics, wellbeing and resilience in the ICT doctoral journey
Yannis
 
Software Engineering Project Presentation Tanisha Tasnuva
Software Engineering Project Presentation Tanisha Tasnuva
tanishatasnuva76
 
ACEP Magazine Fifth Edition on 5june2025
ACEP Magazine Fifth Edition on 5june2025
Rahul
 
The first edition of the AIAG-VDA FMEA.pptx
The first edition of the AIAG-VDA FMEA.pptx
Mayank Mathur
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
 
Computer_vision-photometric_image_formation.pdf
Computer_vision-photometric_image_formation.pdf
kumarprem6767merp
 
Presentación Tomografía Axial Computarizada
Presentación Tomografía Axial Computarizada
Juliana Ovalle Jiménez
 
Webinar On Steel Melting IIF of steel for rdso
Webinar On Steel Melting IIF of steel for rdso
KapilParyani3
 
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...
ijscai
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Class-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdf
takisvlastos
 
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
PREDICTION OF ROOM TEMPERATURE SIDEEFFECT DUE TOFAST DEMAND RESPONSEFOR BUILD...
ijccmsjournal
 
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
FINAL 2013 Module 20 Corrosion Control and Sequestering PPT Slides.pptx
kippcam
 
International Journal of Advance Robotics & Expert Systems (JARES)
International Journal of Advance Robotics & Expert Systems (JARES)
jaresjournal868
 
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...
gerogepatton
 
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