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

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

PPTX
601109769-Pythondyttcjycvuv-Inheritance .pptx
srinivasa gowda
 
PPTX
Inheritance In Java
Darpan Chelani
 
PPTX
Inheritance
SangeethaSasi1
 
PPTX
Object oriented Programming concepts explained(3).pptx
grad25iconinfocus
 
PDF
Inheritance and polymorphism oops concepts in python
deepalishinkar1
 
PPTX
Inheritance in java
yash jain
 
PPTX
Inheritance in java
Ariful Islam
 
PDF
Values
BenEddy
 
PDF
Object oriented programming inheritance
Renas Rekany
 
PPTX
Multiple Inheritance
BhavyaJain137
 
PPTX
Dps_Python1_Ectracted_2345633_Pptx4.pptx
ecomwithfaith
 
PDF
All about python Inheritance.python codingdf
adipapai181023
 
PPTX
Inheritance in java
RahulAnanda1
 
601109769-Pythondyttcjycvuv-Inheritance .pptx
srinivasa gowda
 
Inheritance In Java
Darpan Chelani
 
Inheritance
SangeethaSasi1
 
Object oriented Programming concepts explained(3).pptx
grad25iconinfocus
 
Inheritance and polymorphism oops concepts in python
deepalishinkar1
 
Inheritance in java
yash jain
 
Inheritance in java
Ariful Islam
 
Values
BenEddy
 
Object oriented programming inheritance
Renas Rekany
 
Multiple Inheritance
BhavyaJain137
 
Dps_Python1_Ectracted_2345633_Pptx4.pptx
ecomwithfaith
 
All about python Inheritance.python codingdf
adipapai181023
 
Inheritance in java
RahulAnanda1
 

More from deepuranjankumar08 (8)

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

Recently uploaded (20)

PDF
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
PDF
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
DOCX
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
PPTX
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
PPTX
week 1-2.pptx yueojerjdeiwmwjsweuwikwswiewjrwiwkw
rebznelz
 
PDF
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
PDF
Cooperative wireless communications 1st Edition Yan Zhang
jsphyftmkb123
 
PPTX
Practice Gardens and Polytechnic Education: Utilizing Nature in 1950s’ Hu...
Lajos Somogyvári
 
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
PPTX
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
PPTX
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
PDF
Quiz Night Live May 2025 - Intra Pragya Online General Quiz
Pragya - UEM Kolkata Quiz Club
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
PPTX
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
Comparing Translational and Rotational Motion.pptx
AngeliqueTolentinoDe
 
week 1-2.pptx yueojerjdeiwmwjsweuwikwswiewjrwiwkw
rebznelz
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
Cooperative wireless communications 1st Edition Yan Zhang
jsphyftmkb123
 
Practice Gardens and Polytechnic Education: Utilizing Nature in 1950s’ Hu...
Lajos Somogyvári
 
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
Quiz Night Live May 2025 - Intra Pragya Online General Quiz
Pragya - UEM Kolkata Quiz Club
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
How to Manage Wins & Losses in Odoo 18 CRM
Celine George
 
Ad

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