SlideShare a Scribd company logo
INHERITANCE ppt of python.pptx & PYTHON INHERITANCE PPT
TOPIC NAME : INHERITANCE IN PYTHON
Submitted by :
Nisha kumari
MCA 2nd sem
DEFINITION OF INHERITANCE
 When we define a class that inherits all the
properties of other class called inheritance.
SYNTAX OF INHERITANCE
class class_name1:
properties
Class class_name2(class_name1):
properties
Class class_namen:
properties
EXAMPLE OF INHERITANCE
Class father: #parent class
#properties
Class son(Father): #parent class
#properties
EXAMPLE OF INHERITANCE
Class Father:
def lands(self): output
print(“having 15 ekar lands”) having 10 lakhmoney
Class son(Father): having 10 ekar lands
def money(self):
print(“having 10 lakh money”)
s = son()
s.money()
s.lands()
SOME IMPORTANT POINT
 When we create object of child class then we can access child
class and parent class properties.
 But when we create object of parent class then we can’t access
child class properties.
TYPES OF INHERITANCE
1. Single inheritance
2. Multiple inheritance
3. Multi-level inheritance
4. Hierarchical inheritance
SINGLE INHERITANCE
Single inheritance is nothing but which contains only
one parent class and child class.
Parent--class
Child --class
Example of single inheritance
Class A:
num1= int(input(“Enter 1st no:”)
num2= int(input(“Enter 2st no:”)
def Add(self):
print(“Addition:”,self.num1 + self.num2)
def Sub(self):
print(“Subtraction:”,self.num1 - self.num2)
Class B(A):
def Multi(self):
print(“Multiplication:”,self.num1* self.num2)
def Div(self):
print(“Division:”,self.num1/ self.num2)
Obj = B( )
Obj.Add( )
Obj.Sub( )
Obj.Multi( )
Obj.Div( )
MULTI - LEVEL INHERITANCE
In this inheritance we have one parent class and multiple child
class.
parent--class
Child--class
Child--class
SYNTAX OF MULTI - LEVEL INHERITANCE
Class parent:
#properties
Class child1(parent):
#properties
Class child2(child1):
#properties
Example of multi-level inheritance
Class Father:
surname = “singh”
Class Son(Father):
def show(self):
print(“Ajeet”, self.surname)
Class grandDaughter(Son):
def display(self):
print(“Priya”,self.surname)
S = Son( )
S .show( )
S1 =grandDaughter( )
S1.display( )
S1.show( )
Output
Ajeet singh
Priya singh
Ajeet singh
MULTIPLE INHERITANCE
Multiple inheritance which contains more parents class and
only one child class.
Parent--class Parent--class
Parent--class
Child--class
Example of multiple inheritance
Class A:
a=50
b=30
def sum(self):
print(“sum=“, self.a + self.b)
Class B:
def sub(self):
print(“sub=“, self.a – self.b)
Class C:
def Mul(self):
print(“mul=“,self.a * self.b)
Class D(A,B,C):
def show(self):
print(“successful”)
Example of multiple inheritance
Obj = D()
Obj.sum()
Obj.sub()
Obj.Mul()
Obj.show()
Output
Sum=80
Sub=20
Mul=1500
successful
HIERARCHICAL INHERITANCE
Hierarchical inheritance contains only one parent class and
multiple child classes but each child class can access
parent class property.
Parent--class
Child--class Child--class
Example of hierarchical inheritance
Class Father:
surname = “singh”
def show(self):
print(“my surname is”,self.surname)
Class son(Father):
def name(self):
print(“my name is Ajay kumar”, self.surname)
Class Daughter(Father):
def display(self):
print(“my name is Nisha”,self.surname)
Example of hierarchical inheritance
S = son( )
D=Daughter( )
S.name( )
D.display( )
Output
My name is Ajay kumar singh
My name is Nisha singh
INHERITANCE ppt of python.pptx & PYTHON INHERITANCE PPT

More Related Content

PPTX
Inheritance Super and MRO _
PDF
Object oriented Programning Lanuagues in text format.
PDF
Python programming : Inheritance and polymorphism
PPTX
Inheritance_in_OOP_using Python Programming
PPTX
Python programming computer science and engineering
PPTX
PPTX
Presentation_4516_Content_Document_20250204010703PM.pptx
Inheritance Super and MRO _
Object oriented Programning Lanuagues in text format.
Python programming : Inheritance and polymorphism
Inheritance_in_OOP_using Python Programming
Python programming computer science and engineering
Presentation_4516_Content_Document_20250204010703PM.pptx

Similar to INHERITANCE ppt of python.pptx & PYTHON INHERITANCE PPT (14)

PPTX
601109769-Pythondyttcjycvuv-Inheritance .pptx
PPTX
Inheritance In Java
PPTX
Inheritance
PPTX
Object oriented Programming concepts explained(3).pptx
PDF
Inheritance and polymorphism oops concepts in python
PPTX
Inheritance in java
PPTX
Inheritance in java
PDF
Values
PDF
Object oriented programming inheritance
PPTX
Multiple Inheritance
PPTX
Dps_Python1_Ectracted_2345633_Pptx4.pptx
PDF
All about python Inheritance.python codingdf
PPTX
Inheritance in java
601109769-Pythondyttcjycvuv-Inheritance .pptx
Inheritance In Java
Inheritance
Object oriented Programming concepts explained(3).pptx
Inheritance and polymorphism oops concepts in python
Inheritance in java
Inheritance in java
Values
Object oriented programming inheritance
Multiple Inheritance
Dps_Python1_Ectracted_2345633_Pptx4.pptx
All about python Inheritance.python codingdf
Inheritance in java
Ad

More from deepuranjankumar08 (8)

PPTX
DSA MCA Stack-and-Queue-Data-Structures.pptx
PPTX
JAVA AWA S SEMG HAINH JAVA mar chandan.pptx
PPTX
Introduction to HTML+CSS+Javascript by Deepu.pptx
PPTX
Html,Css,Js INTERNSHIP REPORT By SELF pptx
PPTX
file system vs Dbms file system vs Dbmsppt.pptx
PPT
5g-technology-ppt for seminar report-.ppt
PDF
Array Data Structure for programing language
PPTX
PYTHON inheritance PPT.pptxpython inheritance ppt and inheritance in python
DSA MCA Stack-and-Queue-Data-Structures.pptx
JAVA AWA S SEMG HAINH JAVA mar chandan.pptx
Introduction to HTML+CSS+Javascript by Deepu.pptx
Html,Css,Js INTERNSHIP REPORT By SELF pptx
file system vs Dbms file system vs Dbmsppt.pptx
5g-technology-ppt for seminar report-.ppt
Array Data Structure for programing language
PYTHON inheritance PPT.pptxpython inheritance ppt and inheritance in python
Ad

Recently uploaded (20)

PDF
Sunset Boulevard Student Revision Booklet
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
From loneliness to social connection charting
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Landforms and landscapes data surprise preview
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
IMMUNIZATION PROGRAMME pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Onica Farming 24rsclub profitable farm business
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
High Ground Student Revision Booklet Preview
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Sunset Boulevard Student Revision Booklet
O7-L3 Supply Chain Operations - ICLT Program
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
NOI Hackathon - Summer Edition - GreenThumber.pptx
Insiders guide to clinical Medicine.pdf
From loneliness to social connection charting
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Landforms and landscapes data surprise preview
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
Revamp in MTO Odoo 18 Inventory - Odoo Slides
IMMUNIZATION PROGRAMME pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Onica Farming 24rsclub profitable farm business
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Week 4 Term 3 Study Techniques revisited.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
High Ground Student Revision Booklet Preview
Module 3: Health Systems Tutorial Slides S2 2025
Open Quiz Monsoon Mind Game Prelims.pptx

INHERITANCE ppt of python.pptx & PYTHON INHERITANCE PPT

  • 2. TOPIC NAME : INHERITANCE IN PYTHON Submitted by : Nisha kumari MCA 2nd sem
  • 3. DEFINITION OF INHERITANCE  When we define a class that inherits all the properties of other class called inheritance.
  • 4. SYNTAX OF INHERITANCE class class_name1: properties Class class_name2(class_name1): properties Class class_namen: properties
  • 5. EXAMPLE OF INHERITANCE Class father: #parent class #properties Class son(Father): #parent class #properties
  • 6. EXAMPLE OF INHERITANCE Class Father: def lands(self): output print(“having 15 ekar lands”) having 10 lakhmoney Class son(Father): having 10 ekar lands def money(self): print(“having 10 lakh money”) s = son() s.money() s.lands()
  • 7. SOME IMPORTANT POINT  When we create object of child class then we can access child class and parent class properties.  But when we create object of parent class then we can’t access child class properties.
  • 8. TYPES OF INHERITANCE 1. Single inheritance 2. Multiple inheritance 3. Multi-level inheritance 4. Hierarchical inheritance
  • 9. SINGLE INHERITANCE Single inheritance is nothing but which contains only one parent class and child class. Parent--class Child --class
  • 10. Example of single inheritance Class A: num1= int(input(“Enter 1st no:”) num2= int(input(“Enter 2st no:”) def Add(self): print(“Addition:”,self.num1 + self.num2) def Sub(self): print(“Subtraction:”,self.num1 - self.num2)
  • 11. Class B(A): def Multi(self): print(“Multiplication:”,self.num1* self.num2) def Div(self): print(“Division:”,self.num1/ self.num2) Obj = B( ) Obj.Add( ) Obj.Sub( ) Obj.Multi( ) Obj.Div( )
  • 12. MULTI - LEVEL INHERITANCE In this inheritance we have one parent class and multiple child class. parent--class Child--class Child--class
  • 13. SYNTAX OF MULTI - LEVEL INHERITANCE Class parent: #properties Class child1(parent): #properties Class child2(child1): #properties
  • 14. Example of multi-level inheritance Class Father: surname = “singh” Class Son(Father): def show(self): print(“Ajeet”, self.surname) Class grandDaughter(Son): def display(self): print(“Priya”,self.surname) S = Son( ) S .show( ) S1 =grandDaughter( ) S1.display( ) S1.show( ) Output Ajeet singh Priya singh Ajeet singh
  • 15. MULTIPLE INHERITANCE Multiple inheritance which contains more parents class and only one child class. Parent--class Parent--class Parent--class Child--class
  • 16. Example of multiple inheritance Class A: a=50 b=30 def sum(self): print(“sum=“, self.a + self.b) Class B: def sub(self): print(“sub=“, self.a – self.b) Class C: def Mul(self): print(“mul=“,self.a * self.b) Class D(A,B,C): def show(self): print(“successful”)
  • 17. Example of multiple inheritance Obj = D() Obj.sum() Obj.sub() Obj.Mul() Obj.show() Output Sum=80 Sub=20 Mul=1500 successful
  • 18. HIERARCHICAL INHERITANCE Hierarchical inheritance contains only one parent class and multiple child classes but each child class can access parent class property. Parent--class Child--class Child--class
  • 19. Example of hierarchical inheritance Class Father: surname = “singh” def show(self): print(“my surname is”,self.surname) Class son(Father): def name(self): print(“my name is Ajay kumar”, self.surname) Class Daughter(Father): def display(self): print(“my name is Nisha”,self.surname)
  • 20. Example of hierarchical inheritance S = son( ) D=Daughter( ) S.name( ) D.display( ) Output My name is Ajay kumar singh My name is Nisha singh