Polymorphism in Python in Hindi

What is Polymorphism in Python

Polymorphism, Object-Oriented Programming का एक concept है, python classes and objects programming  मे जब एक function, method या operator different contexts मे different types के objects के साथ काम करता है तो इस concept को polymorphism कहते है।

Key Concepts of Polymorphism

Method Overriding: Polymorphism मे method overriding तब होता है जब child class अपने parent class के method को redefine कर देता है। 

Method Overloading: जब एक ही class मे multiple methods, same name लेकिन different parameters के साथ होते है तब Method Overriding होती है। 

Operator Overloading: Python मे operators को objects के साथ differently behave करने के लिए redefine कर सकते है।

Types of Polymorphism

Polymorphism with Functions and Objects

Python मे हम एक single function को different types के objects के साथ use कर सकते है, ये इस बात पर depend करता है कि object का class क्या provide करता है।

Polymorphism with Inheritance

Inheritance के through polymorphism को achive कर सकते है जहां child class अपने parent class के method को override करता है।

Operator Overloading

Operator Overloading मे operator different objects के साथ different types से behave करता है, इसे हम methods के through achieve कर सकते है।

Abstraction

अगर हम चाहते है की किसी class मे कुछ important methods जरूर define किए जाए तो उसके लिए हम abstraction का use का करते है, example के लिए अगर हमे कोई animal नाम का class बनाया या और उसमे एक किसी animal के speak जानने के लिए एक method speak() है तो हमे चाहेंगे की जब भी इस animal class को कोई subclass cat, dog etc. बनाया जाए तो उसमे ये speak() method जरूर define किया हो क्योंकि हर animal का speak करता है, ऐसे मे हम abstaction का use करेंगे, जिससे हर subclass मे speak() method define करना जरूरी हो जाएगा अगर हम define नहीं करेंगे हो हमे error मिलेगा। 

Abstraction class creatte करने के लिए “abc” module से “ABC” और  “abstractmethod” को import करना होता है फिर “ABC” को उस class का parent class बना देंगे जिसे abstact करना हो और abstactmethod को उस method के ऊपर as a decorator use करेंगे जिसे abstract बनाना हो। 

उम्मीद करते है कि आपको Python Classes and Objects का एक useful concept Polymorphism अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Add a comment...

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Electronics
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
computer networks

Table of Contents All Chapters 1. OSI Model      1.1. Physical Layer      1.2. Data Link Layer  ...

computer networks

Table of Contents All Chapters 1. Topology 2. Types of Topology      2.1. Point to Point Topology    ...

computer networks

Table of Contents All Chapters 1. Data Communication 2. Types of Data Communication      2.1. Simplex      2.2....

digital electronics number system

Table of Contents All Chapters 1. Logic Gate 2. AND Gate      2.1. AND Gate Truth Table 3. OR...

Edit Template

Sign up to track your learning

Login to continue your learning tracking

To reset your password, please enter your email address or username below.

Scroll to Top