Python Inheritance

Python Inheritance In Hindi – OOPs In Hindi

Python

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

For Example:- Derived Class Kar Sakta Hai Parent Class Ke Properties Ko |

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 Inheritance In Hindi

Inheritance OOP 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(Parent): Base class Ko parent class Bhi Kaha Jata Hain |
  • Derived Class(Child): Derived class Ko sub Ya child class Bhi Kaha Jata Hain| Derived class Ye Base class Ki properties या attributes Ko inherit Karta Hai |

Syntax:

class Base:
	Base_Class_Body
class Derived(Base):
	Derived_Class_Body

Example 1:

class Parent:
    def show(self):
        print("Parent method")
class Child(Parent):
    def display(self):
        print("Child method")
c = Child()
c.display()
c.show()

Output:

Child method
Parent method

Example 2:

class Employee:
	"Class Employee"
    def set1(self,empid,name,salary):        
        self.empid = empid
        self.name = name
        self.salary = salary
class Fitness(Employee):
    "Class Fitness"
	def set2(self,height,weight):
        self.height = height
        self.weight = weight
    def display(self):
        print("id is",self.empid)
        print("name is",self.name)
        print("salary is",self.salary,"Rs")
        print("height is",self.height,"cm")
        print("weight is",self.weight,"Kg")

obj = Fitness()
obj.set1(1,"Danish",15000)
obj.set2(166,45)
obj.display()

Output:

id is 1
name is Danish
salary is 15000 Rs
height is 166 cm
weight is 45 Kg

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 |

Abhi Tak Keval Single Inheritance Ko Cover Kiya Hain Lekin Next Post Mai Ham Multiple And Multilevel Inheritance Ko Cover Karne Wale Hain |

Leave a Reply

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