Seedha content par jao
🤖 Python Hindi Bot
Namaste! Main Python Hindi Bot hoon 🐍
Python ya AI se related kuch bhi type karke pucho, ya neeche se quick sawaal chuno.
WhatsApp

Stay Connected with PythonHindii

Join our WhatsApp Community to get the latest Python tutorials, coding tips, interview questions, project updates, and learning resources directly on your phone.

Join WhatsApp Community
⇧
Python Hindi Logo
Python in Hindi | Programming Education
🎓 100% Free · Hindi me · Beginner se Career tak

Python Tutorial in HindiiLearn Python Programming for Free

Python, AI, Data Analytics aur SQL ek hi jagah, simple Hindi me. Padho, browser me code chalao, projects banao aur career shuru karo.

main.py
# Python seekho, Hindi me naam = "Ravi" for i in range(3): print("Namaste", naam)
▸ python main.py
🐍 Python 🤖 AI & ML 📊 Data 🗄️ SQL

Chahe Student ho ya Professional, yahan aapke liye sab hai

Apna card chuno, seedha sahi jagah pahunch jaoge.

🎓

Student ho?

School ya college me ho? Python zero se seekho, notes aur cheat sheets ke saath.

  • Python basics se OOP tak
  • Notes, PDFs aur Cheat Sheets
  • Browser me practice, kuch install nahi
💼

Working Professional ho?

Kaam ke saath nayi skill jodo: data, SQL aur AI se apna kaam tez karo.

  • Pandas, NumPy, Excel, Power BI
  • SQL aur MySQL databases
  • Automation aur AI Tools
🚀

Job ya Career change?

Projects banao, interview ki taiyari karo aur sahi roadmap follow karo.

  • Real projects, portfolio ke liye
  • Python aur SQL interview questions
  • AI Engineer, Data Scientist roadmap

Python Hindii Kaise Kaam Karta Hai?

Ek hi jagah 4 layers: seekho, practice karo, skills banao aur career shuru karo. Har layer ek step hai, us par click karke seedha wahan pahuncho. Computer par drag karke 3D me ghumao bhi.

Layer 1 · Seekho

Python Basics se Advanced tak

Variables, loops, functions se OOP tak, sab simple Hindi me. Yahin se shuru karo.

Naye ho? 3 step me shuru karo

💻 Online Code Editor

Browser me hi code likho aur turant chalao

Koi software install nahi. Code likho, Run dabao aur result usi waqt dekho.

  • Python, Java, C, C++, JavaScript, HTML aur aur bhi languages
  • input(), graphs aur multi-file HTML project bhi chalte hain
  • Mobile aur computer, dono par chalta hai
main.py
naam = input("Naam batao: ") for i in range(3): print("Namaste", naam)
▸ python main.py
PythonJavaCC++JavaScriptHTML

Python se AI tak ka poora rasta

8 steps, ek ke baad ek. Aage-peeche ghumao aur apni stage se seedha shuru karo.

Step 1 🐍

Python Basics

IntroductionVariablesData TypesOperatorsInput & OutputConditionsLoops
Start Python →
Step 2 💻

Python Intermediate

ListsTuplesSetsDictionariesStringsModulesFile Handling
Continue Python →
Step 4 🗄️

SQL & Databases

SQL BasicsMySQLSELECTINSERTUPDATEDELETEJOIN
Learn SQL →
Step 5 📊

Data Analytics

NumPyPandasData CleaningData VisualizationMatplotlibExploratory Data Analysis
Learn Data Analytics →
Step 6 🤖

Machine Learning

ML BasicsSupervised & Unsupervised LearningRegressionClassificationModel EvaluationScikit-learn
Learn Machine Learning →
Step 7 🧠

Artificial Intelligence

AI FundamentalsGenerative AIAI ToolsPrompt EngineeringLLM ConceptsAI Automation
Explore AI →
Step 8 🚀

Projects & Career

Python ProjectsAI ProjectsData ProjectsPortfolioGitHubInterview PreparationCareer Roadmap
Build Your Career →
Step 1 / 8

Python Polymorphism in Hindi | Polymorphism क्या है? | Complete Python Course 2026

Python Polymorphism in Hindi - Complete Python Course 2026

Python Polymorphism

OOP के चार मुख्य स्तंभों में से एक है Polymorphism — एक ऐसा शब्द जो सुनने में भारी लगता है, लेकिन असल में इसका idea बहुत ही natural और रोज़मर्रा की जिंदगी जैसा है। इस lesson में हम इसे पूरी तरह, practical Python examples के साथ समझेंगे।

अगर आपने अभी Python Classes & Objects नहीं पढ़ा है, तो पहले उसे पढ़ना जरूरी है, क्योंकि Polymorphism पूरी तरह Classes, Objects और Methods पर आधारित है। Examples खुद run करने के लिए हमारा Online Python Editor & Compiler use कर सकते हैं।

⚠️ इस Lesson का Scope: इस lesson का focus Polymorphism के basic idea, Duck Typing, और Method Overriding की बुनियादी समझ पर है। Inheritance की पूरी detail, Encapsulation और Abstraction को यहाँ detail में नहीं पढ़ाया जाएगा — इन्हें आगे dedicated lessons में अलग-अलग समझाया जाएगा।

Polymorphism क्या है?

Polymorphism OOP का एक सिद्धांत है, जिसमें एक ही action या method अलग-अलग Objects पर अलग-अलग तरीके से काम करता है।

सरल भाषा में — एक जैसी "बात कहने" का तरीका अलग-अलग चीज़ों के लिए अलग-अलग असर डाल सकता है।

Poly और Morph का Meaning

यह शब्द दो Greek words से मिलकर बना है:

Wordमतलब
Polyकई, अनेक (Many)
Morphरूप, आकार (Forms)
Polymorphism"कई रूप" — यानी एक ही चीज़ के कई अलग-अलग रूप

Polymorphism का Basic Idea

रोज़मर्रा की जिंदगी से एक उदाहरण लें — शब्द "Sound" (आवाज़)। अगर हम किसी भी जानवर को बोलें "अपनी Sound निकालो", तो:

  • एक Dog भौंकेगा — "Woof!"
  • एक Cat म्याऊं करेगी — "Meow!"
  • एक Cow रंभाएगी — "Moo!"

यहाँ instruction एक ही है — "अपनी Sound निकालो" — लेकिन हर जानवर उसे अपने तरीके से respond करता है। Programming में Polymorphism का idea बिल्कुल यही है — एक जैसा call, लेकिन Object के हिसाब से अलग-अलग result।

🎥 Video में पूरा Topic समझें

Same Function, Different Behavior

Python में built-in functions भी Polymorphism दिखाते हैं — एक ही function अलग-अलग data types पर अलग तरीके से काम करता है।

Example — len() function
print(len("Python")) print(len([1, 2, 3, 4])) print(len({"name": "Ankit", "age": 25}))

Output:

6 4 2

len() हर बार एक जैसा ही call हुआ, लेकिन string, list और dictionary — तीनों पर उसका behavior अलग था।

Try it Yourself »
Example — + operator
print(5 + 10) print("Python" + " Hindi") print([1, 2] + [3, 4])

Output:

15 Python Hindi [1, 2, 3, 4]

+ operator numbers के लिए addition करता है, strings के लिए जोड़ता है (concatenation), और lists के लिए उन्हें मिला देता है — यह भी एक तरह का Polymorphism है।

Try it Yourself »

Same Method, Different Behavior

अब इसे अपनी खुद की Classes में देखते हैं। अलग-अलग Classes में एक जैसे नाम का method हो सकता है, लेकिन हर Class में उसका behavior अलग हो सकता है।

Example
class Dog: def sound(self): print("Woof!") class Cat: def sound(self): print("Meow!") dog1 = Dog() cat1 = Cat() dog1.sound() cat1.sound()

Output:

Woof! Meow!

दोनों Classes में method का नाम sound एक जैसा है, लेकिन हर Class में उसकी definition अलग है, इसलिए behavior भी अलग है।

Try it Yourself »

Different Objects के साथ Common Function

Polymorphism की असली power तब दिखती है जब एक ही function या loop, अलग-अलग Objects पर उनका अपना-अपना method call कर पाता है — बिना यह जाने कि कौन सा Object आगे आएगा।

Example
class Dog: def sound(self): print("Woof!") class Cat: def sound(self): print("Meow!") class Cow: def sound(self): print("Moo!") animals = [Dog(), Cat(), Cow()] for animal in animals: animal.sound()

Output:

Woof! Meow! Moo!

Loop को यह जानने की जरूरत नहीं पड़ी कि list में कौन सा Object है — उसने बस animal.sound() call किया, और हर Object ने अपने हिसाब से सही behavior दिखाया।

Try it Yourself »

Python में Duck Typing

Python में Polymorphism का एक खास तरीका है, जिसे Duck Typing कहा जाता है। इसका idea इस कहावत से आता है:

"अगर कोई चीज़ बत्तख की तरह चलती है और बत्तख की तरह आवाज़ निकालती है, तो वह शायद बत्तख ही है।"

यानी Python यह नहीं पूछता कि Object किस Class का है — वह बस यह check करता है कि उस Object के पास वह method या behavior मौजूद है या नहीं।

Example
class Dog: def sound(self): print("Woof!") class Car: def sound(self): print("Vroom!") def make_it_sound(thing): thing.sound() make_it_sound(Dog()) make_it_sound(Car())

Output:

Woof! Vroom!

make_it_sound() function को कोई फर्क नहीं पड़ा कि उसे Dog दिया गया या Car — उसे बस इतना चाहिए था कि object के पास sound() नाम का method हो। इसी सोच को Duck Typing कहा जाता है।

Try it Yourself »

Method Overriding का Basic Concept

Method Overriding तब होता है जब एक Class (जिसे parent/base Class से inherit किया गया है) अपने parent के किसी method को अपने तरीके से फिर से define करती है। यह Polymorphism का एक बहुत common तरीका है।

Example
class Animal: def sound(self): print("Animal makes a sound") class Dog(Animal): def sound(self): print("Dog barks: Woof!") a = Animal() d = Dog() a.sound() d.sound()

Output:

Animal makes a sound Dog barks: Woof!

Dog ने Animal के sound() method को अपने तरीके से फिर से लिख दिया — इसे Overriding कहा जाता है। (Dog(Animal) में लिखा Animal एक Inheritance का उदाहरण है, जिसकी पूरी detail आगे किसी dedicated lesson में समझाई जाएगी।)

Try it Yourself »

Real-World Payment Example

अब Polymorphism को एक practical, real-world जैसी situation में देखते हैं — एक payment system, जहाँ अलग-अलग payment methods का अपना-अपना तरीका होता है।

Example
class CreditCardPayment: def pay(self, amount): print("Paid", amount, "using Credit Card") class UpiPayment: def pay(self, amount): print("Paid", amount, "using UPI") class CashPayment: def pay(self, amount): print("Paid", amount, "using Cash") payments = [CreditCardPayment(), UpiPayment(), CashPayment()] for method in payments: method.pay(500)

Output:

Paid 500 using Credit Card Paid 500 using UPI Paid 500 using Cash

हर payment method का अपना pay() तरीका है, लेकिन loop में उन्हें एक जैसे तरीके से call किया जा सकता है — बिल्कुल वैसे ही जैसे real-world में किसी app में "Pay" button एक ही होता है, चाहे आप कोई भी payment method चुनें।

Try it Yourself »

Polymorphism के Practical Benefits

  • Code को ज्यादा flexible बनाता है — एक ही code अलग-अलग तरह के Objects के साथ काम कर सकता है
  • नई चीज़ें जोड़ना आसान बनाता है — एक नया payment method जोड़ने के लिए बाकी code बदलने की जरूरत नहीं
  • Code को readable और predictable बनाता है — हर जगह एक जैसा interface (जैसे .pay(), .sound()) इस्तेमाल होता है
  • Real-world systems को naturally represent करता है — अलग-अलग चीज़ों का common "काम" होना एक natural concept है

Objects के अलग-अलग Behavior को समझना

Polymorphism को समझने की सबसे आसान कसौटी यही है — method call हमेशा एक जैसा दिखता है, लेकिन असली काम इस बात पर depend करता है कि वह किस Object पर किया जा रहा है।

Call (हमेशा same दिखता है)ObjectActual Behavior
method.pay(500)CreditCardPaymentCredit Card से payment
method.pay(500)UpiPaymentUPI से payment
method.pay(500)CashPaymentCash से payment

Common Beginner Mistakes

❌ हर Class में Method का नाम अलग रखना
class CreditCardPayment: def pay_by_card(self, amount): ... class UpiPayment: def pay_by_upi(self, amount): ...

अगर हर Class में method का नाम अलग होगा, तो उन्हें एक जैसे तरीके से loop में call नहीं किया जा सकता — Polymorphism का पूरा फायदा खत्म हो जाता है।

✅ सही तरीका — नाम एक जैसा रखें
class CreditCardPayment: def pay(self, amount): ... class UpiPayment: def pay(self, amount): ...
❌ Polymorphism को Inheritance जैसा ही समझना

Polymorphism और Inheritance जुड़े जरूर हैं, लेकिन एक जैसे नहीं हैं। Polymorphism सिर्फ "एक जैसा call, अलग behavior" के बारे में है — यह Duck Typing से भी हो सकता है, बिना किसी Inheritance के (जैसा ऊपर Dog और Car example में देखा)।

❌ यह सोचना कि Polymorphism सिर्फ अपनी Classes में होता है

Python के built-in functions जैसे len() और operators जैसे + भी Polymorphism दिखाते हैं — यह सिर्फ custom Classes तक सीमित नहीं है।

VS Code में Practical Python Coding

अब इसे खुद VS Code में try करते हैं। एक नई file polymorphism_demo.py बनाइए और यह code लिखिए:

polymorphism_demo.py
class CreditCardPayment: def pay(self, amount): print("Paid", amount, "using Credit Card") class UpiPayment: def pay(self, amount): print("Paid", amount, "using UPI") def process_payment(method, amount): method.pay(amount) process_payment(CreditCardPayment(), 1200) process_payment(UpiPayment(), 750)

File save करके VS Code के Terminal में इसे run कीजिए।

Terminal में Output

$ python polymorphism_demo.py Paid 1200 using Credit Card Paid 750 using UPI

process_payment() function को यह जानने की जरूरत नहीं पड़ी कि कौन सा payment method आएगा — उसने बस .pay() call किया, और सही behavior अपने-आप मिल गया।

Exercise ?

जब एक जैसा method call अलग-अलग Objects पर अलग-अलग तरीके से काम करता है, उसे क्या कहते हैं?

Encapsulation
Polymorphism
Abstraction

Practical Coding Challenge

अब खुद अपने VS Code या Online Python Editor में यह challenge solve कीजिए:

  1. तीन अलग Classes बनाइए — Circle, Square, Rectangle — हर एक में एक area(self) method हो।
  2. हर Class के area() method में उसका अपना area-calculation logic लिखिए (values को directly set करके, self.side = 5 जैसे)।
  3. तीनों के objects एक list में रखिए और एक loop से सबका area() call करके print कीजिए।
  4. एक Bird और एक Airplane Class बनाइए, दोनों में एक fly(self) method हो — और उन्हें Duck Typing style में एक common function से call कीजिए।
  5. खुद से सोचिए — अगर दोनों Classes में method का नाम अलग-अलग होता (जैसे bird_fly() और airplane_fly()), तो loop वाला तरीका क्यों काम नहीं करता?

Quick Revision

Conceptमतलब
Polymorphismएक जैसा call, अलग-अलग Objects पर अलग behavior
Poly + Morph"कई" + "रूप" = कई रूप
Duck TypingClass नहीं, बल्कि behavior (method मौजूद है या नहीं) मायने रखता है
Method OverridingChild Class द्वारा parent के method को फिर से define करना

FAQ

Python में Polymorphism क्या है?

Polymorphism OOP का एक सिद्धांत है, जिसमें एक ही method या function अलग-अलग Objects पर अलग-अलग तरीके से काम करता है।

Duck Typing क्या है?

Duck Typing Python का एक तरीका है, जिसमें यह नहीं देखा जाता कि Object किस Class का है, बल्कि यह देखा जाता है कि उसके पास जरूरी method/behavior मौजूद है या नहीं।

Method Overriding और Polymorphism में क्या संबंध है?

Method Overriding Polymorphism को लागू करने का एक common तरीका है, जिसमें एक child Class अपने parent Class के किसी method को अपने तरीके से फिर से define करती है।

क्या Polymorphism के लिए Inheritance जरूरी है?

नहीं। Python में Duck Typing की मदद से बिना किसी Inheritance के भी Polymorphism हासिल किया जा सकता है — जैसा Dog और Car वाले example में देखा गया।

Polymorphism का सबसे बड़ा फायदा क्या है?

Polymorphism से code ज्यादा flexible और reusable बनता है — एक ही loop या function अलग-अलग तरह के Objects के साथ काम कर सकता है, जिससे नई चीज़ें जोड़ना आसान हो जाता है।

Summary

Polymorphism = एक जैसा call, लेकिन Object के हिसाब से अलग-अलग result।

इस lesson में आपने सीखा कि Polymorphism क्या है, Poly और Morph का meaning क्या है, Python के built-in functions में भी Polymorphism कैसे दिखता है, Duck Typing क्या है, Method Overriding का basic concept क्या है, और एक real-world Payment example से इसे practically कैसे इस्तेमाल किया जाता है।

Polymorphism को समझ लेने के बाद आप code को ज्यादा flexible और reusable तरीके से लिख पाएंगे। अब ऊपर दिया गया coding challenge खुद VS Code या Online Editor में solve करें।

Related Articles

🧑‍💻 Python Coding Lab

Python code likho, run karo aur practice karo — directly browser mein.