Table of Contents
Python Tutorial
Table of Contents
Python Tutorial
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 करे,
- 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

Table of Contents All Chapters 1. Personal Area Network 2. Local Area Network 3. Campus Area Network 4. Metropolitan Area...

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

Table of Contents All Chapters 1. Special Logic Gate 2. XOR Gate 2.1. XOR Gate Truth Table 3....

Table of Contents All Chapters 1. Universal Logic Gates 2. NOR Gate 2.1. NOR Gate Truth Table 3....

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

Table of Contents All Chapters 1. Simplification 2. Simplification using Boolean Algebra Theorems 3. Simplification using K-map Digital Electronics...

Table of Contents All Chapters 1. Identity Laws 2. Null Laws 3. Domination Laws 4. Idempotent Laws 5. Complement Laws...