Python Multilevel Inheritance

Python Multilevel Inheritance In Hindi – OOPs In Hindi

Python

Python Multilevel Inheritance In HindiOOPs In Hindi:- Python Inheritance Allows Karta Hai Hame Ki Class Define Karo Uske Bad Ham Inherits Kar Sakte Hai All Methods And Properties Yani Dusri Class Ke |

Read Also :- Python Classes and Objects

What Is Inheritance In Hindi

Contents

Ek Bar Ek Parent Class Ko Create Karne Ke Bad Ham Parent Class (Base Class ) Ko Ham Derived Class (Sub Class ) Me Istemal kar Sakte Hain And Parent Class Or Derived Class Ke Features To Alag-Alag Honge Hi. Lekin Ham Derived Class Se Parent Class Ke Features Ka Istemal Kar Sakte Hain |

Python Multilevel Inheritance In Hindi

Inheritance OOPs Ka Ek Part Hota Hain And Inheritance Mai Ek Se Jyada Classes Hote Hain |

Inheritance In Python in Hindi Ko Understand Karne Ke Liye Upper Diye Image Ka Example Dekhte Hain

Jaise Aap Dekh Sakte Hai Hamne Ek Parent Class (Vehicle) Create Ki Hain Or Vehicle Mai Koi Type Ke Vahical Hote Unke Liye Hamne Derived Class (Car, Bus, Bike ) Alag- Alag Create Ki Or Ab Inhe Derived Class Se Parent Class Ke Features Ka Istemal Kar Sakte Hain.

Read Also :- Python OOPS Concepts

Inheritance Ko 2 Class Dena Jaruri Hota Hain |

  • Base Class 1 (Parent 1): Base class Ko parent class Bhi Kaha Jata Hain.
  • Derived Class 2 (Base Class 1)Derived class Ko Sub Ya child class Bhi Kaha Jata Hain| Derived class Ye Base class Ki properties Ya attributes Ko inherit Karta Hai |
  • MultiLevel Derived Class(Derived Class 2)Derived class Ko sub Ya child class Bhi Kaha Jata Hain| Derived class Ye Derived Class 2 Or Base class Ki properties Ya attributes Ko inherit Karta Hai |
Multilevel Inheritance in Python

Syntax:

class Base:
    pass

class Derived1(Base):
    pass

class Derived2(Derived1):
    pass

Example 1:

# Python program to demonstrate 
# multilevel inheritance 


# Base class 
class Grandfather: 
	grandfathername ="" 
	def grandfather(self): 
		print(self.grandfathername) 

# Intermediate class 
class Father(Grandfather): 
	fathername = "" 
	def father(self): 
		print(self.fathername) 

# Derived class 
class Son(Father): 
	def parent(self): 
		print("GrandFather :", self.grandfathername) 
		print("Father :", self.fathername) 

# Driver's code 
s1 = Son() 
s1.grandfathername = "Lalit"
s1.fathername = "Ankur"
s1.parent() 

Output:

GrandFather : Lalit
Father : Ankur

Yadi Aapne  HTML Full Course  And CSS Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

Types Of Inheritance in Python in Hindi

Python Mai Inheritance 3 Types Ke Hote Hain | Lekin Jo Hamne Abhi Read Kiya Hain Yah Ek Single Inheritance Hain |

Leave a Reply

Your email address will not be published. Required fields are marked *