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
Inheritance in java
RahulAnanda1
 
PPTX
Class, object and inheritance in python
Santosh Verma
 
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
PPTX
Super keyword in java
Hitesh Kumar
 
PPTX
OOPS In JAVA.pptx
Sachin33417
 
PPTX
Constructors in C++
RubaNagarajan
 
PPTX
Basics of Object Oriented Programming in Python
Sujith Kumar
 
PPTX
OOPS Basics With Example
Thooyavan Venkatachalam
 
PPTX
Inheritance in java
Tech_MX
 
PPTX
Java abstract class & abstract methods
Shubham Dwivedi
 
PPTX
Chapter 07 inheritance
Praveen M Jigajinni
 
PPSX
Modules and packages in python
TMARAGATHAM
 
PDF
Java Thread Synchronization
Benj Del Mundo
 
PDF
C++ OOPS Concept
Boopathi K
 
PDF
Functions and modules in python
Karin Lagesen
 
PPTX
Inheritance in JAVA PPT
Pooja Jaiswal
 
PPTX
Python: Modules and Packages
Damian T. Gordon
 
PDF
Python basic
Saifuddin Kaijar
 
Inheritance in java
RahulAnanda1
 
Class, object and inheritance in python
Santosh Verma
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Super keyword in java
Hitesh Kumar
 
OOPS In JAVA.pptx
Sachin33417
 
Constructors in C++
RubaNagarajan
 
Basics of Object Oriented Programming in Python
Sujith Kumar
 
OOPS Basics With Example
Thooyavan Venkatachalam
 
Inheritance in java
Tech_MX
 
Java abstract class & abstract methods
Shubham Dwivedi
 
Chapter 07 inheritance
Praveen M Jigajinni
 
Modules and packages in python
TMARAGATHAM
 
Java Thread Synchronization
Benj Del Mundo
 
C++ OOPS Concept
Boopathi K
 
Functions and modules in python
Karin Lagesen
 
Inheritance in JAVA PPT
Pooja Jaiswal
 
Python: Modules and Packages
Damian T. Gordon
 
Python basic
Saifuddin Kaijar
 

Similar to CLASS OBJECT AND INHERITANCE IN PYTHON (20)

PPTX
Problem solving with python programming OOP's Concept
rohitsharma24121
 
PPTX
Class and Objects in python programming.pptx
Rajtherock
 
PDF
Unit 3-Classes ,Objects and Inheritance.pdf
Harsha Patil
 
PPTX
arthimetic operator,classes,objects,instant
ssuser77162c
 
PPT
inheritance in python with full detail.ppt
ssuser7b0a4d
 
PPTX
Python programming computer science and engineering
IRAH34
 
PPTX
Object Oriented Programming.pptx
SAICHARANREDDYN
 
PDF
Object-Oriented Programming System presentation
PavanKumarPathipati
 
PDF
Object oriented Programning Lanuagues in text format.
SravaniSravani53
 
PDF
All about python Inheritance.python codingdf
adipapai181023
 
PPTX
python1 object oriented programming.pptx
PravinBhargav1
 
PPTX
OOPS.pptx
NitinSharma134320
 
PPTX
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
PPTX
INHERITANCE ppt of python.pptx & PYTHON INHERITANCE PPT
deepuranjankumar08
 
PPTX
oops-in-python-240412044200-2d5c6552.pptx
anilvarsha1
 
PPTX
OOP concepts -in-Python programming language
SmritiSharma901052
 
PDF
Inheritance and polymorphism oops concepts in python
deepalishinkar1
 
PPTX
601109769-Pythondyttcjycvuv-Inheritance .pptx
srinivasa gowda
 
PPTX
software construction and development week 3 Python lists, tuples, dictionari...
MuhammadBilalAjmal2
 
PPTX
Inheritance
JayanthiNeelampalli
 
Problem solving with python programming OOP's Concept
rohitsharma24121
 
Class and Objects in python programming.pptx
Rajtherock
 
Unit 3-Classes ,Objects and Inheritance.pdf
Harsha Patil
 
arthimetic operator,classes,objects,instant
ssuser77162c
 
inheritance in python with full detail.ppt
ssuser7b0a4d
 
Python programming computer science and engineering
IRAH34
 
Object Oriented Programming.pptx
SAICHARANREDDYN
 
Object-Oriented Programming System presentation
PavanKumarPathipati
 
Object oriented Programning Lanuagues in text format.
SravaniSravani53
 
All about python Inheritance.python codingdf
adipapai181023
 
python1 object oriented programming.pptx
PravinBhargav1
 
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
INHERITANCE ppt of python.pptx & PYTHON INHERITANCE PPT
deepuranjankumar08
 
oops-in-python-240412044200-2d5c6552.pptx
anilvarsha1
 
OOP concepts -in-Python programming language
SmritiSharma901052
 
Inheritance and polymorphism oops concepts in python
deepalishinkar1
 
601109769-Pythondyttcjycvuv-Inheritance .pptx
srinivasa gowda
 
software construction and development week 3 Python lists, tuples, dictionari...
MuhammadBilalAjmal2
 
Inheritance
JayanthiNeelampalli
 
Ad

Recently uploaded (20)

PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPT
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PDF
Digital water marking system project report
Kamal Acharya
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Design Thinking basics for Engineers.pdf
CMR University
 
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
Digital water marking system project report
Kamal Acharya
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
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