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 If Else in Hindi | if, elif aur else Conditions Explained 2026

Python If Else in Hindi - If, Elif, Else Conditions Explained

अगर आप Python अभी-अभी सीखना शुरू कर रहे हैं, तो एक स्टेज ऐसी जरूर आता  है जहाँ program को खुद फैसला लेना पड़ता है — कि आगे कौन सा रास्ता चुनना है। जैसे किसी student के marks 33 से ऊपर हैं तो उसे Pass दिखाना है, वरना Fail। या फिर age 18 से ज्यादा है तो वह व्यक्ति vote कर सकता है, या  नहीं तो नहीं।

यही "फैसला लेने" वाला काम Python में if, elif और else की मदद से होता है। इन्हें Python में Conditional statements या decision making statements कहा जाता है।

इस पोस्ट में हम Python If Else को शुरुआत से, एकदम practical examples के साथ समझेंगे — ताकि आप सिर्फ syntax याद न करें, बल्कि यह समझें कि real programs में इसका इस्तेमाल कैसे होता है।

अगर आपने अभी तक Python Tutorial in Hindi वाली पार्ट नहीं देखा , तो पहले basics पर एक नज़र डाल लें — इससे आगे का कॉन्सेप्ट समझना और आसान हो जाएगा।

Python में Conditional Statement आखिर होता क्या है?

Simple शब्दों में — conditional statement का मतलब है कि program पहले एक condition check करे, और उसके result (True या False) के हिसाब से decide करे कि आगे क्या करना है।

age = 20

if age >= 18:
    print("आप vote कर सकते हैं")

यहाँ Python सबसे पहले age>= 18  वाली condition check करेगा। अगर यह True निकली, तभी नीचे वाली line execute होगी।

Output:
आप vote कर सकते हैं

और अगर condition False होती, तो print() बिल्कुल भी execute नहीं होता — Python बस उस block को skip कर जाता।

Python If Statement — सबसे पहला कदम

if, Python की सबसे basic conditional statement है। इसका इस्तेमाल तब होता है जब हमें सिर्फ एक ही condition के true होने पर कुछ काम करवाना हो।

Syntax

if condition:
    statement

ध्यान रहे — condition के बाद colon (:) लगाना जरूरी है, और अंदर लिखा गया code proper indentation के साथ होना चाहिए।

Example

marks = 75

if marks >= 33:
    print("Student Pass है")

Output:
Student Pass है

यहाँ marks >= 33 हमारी condition है। अगर यह True है तो message print होगा, वरना कुछ नहीं होगा — क्योंकि अभी हमने else नहीं लगाया।

Python में If Else — जब दूसरा रास्ता भी चाहिए

सिर्फ if की एक limitation है — अगर condition false हो जाए, तो कोई दूसरा काम कैसे करवाएँ? इसी के लिए else आता है। if का condition true होने पर पहला block चलता है, और false होने पर else वाला block।

Syntax

if condition:
    statement_if_true
else:
    statement_if_false

Example

marks = 25

if marks >= 33:
    print("Pass")
else:
    print("Fail")

Output:
Fail

25 >= 33 false है, इसलिए if वाला code skip हो गया और else वाला block चल गया।

एक Real-Life Example — Login System

password = "python123"

if password == "python123":
    print("Login Successful")
else:
    print("Wrong Password")

Output:
Login Successful

यही pattern लगभग हर login form, हर form-validation और हर छोटे-बड़े web app में कहीं न कहीं इस्तेमाल होता है।

Comparison Operators — Conditions की नींव

Condition बनाने के लिए comparison operators सबसे ज्यादा काम आते हैं:

Operatorमतलब
==बराबर
!=बराबर नहीं
>बड़ा
<छोटा
>=बड़ा या बराबर
<=छोटा या बराबर

इन operators की पूरी डिटेल आप Python Operators in Hindi वाली पोस्ट में देख सकते हैं (यहाँ अपनी existing Operators पोस्ट का लिंक लगाएँ)।

Multiple Conditions — जब एक Condition काफी नहीं है

कई बार सिर्फ एक condition से काम नहीं चलता, और, or, not जैसे logical operators तब मदद करते हैं।

age = 20
has_id = True

if age >= 18 and has_id:
    print("Entry Allowed")
else:
    print("Entry Not Allowed")

Output:
Entry Allowed

यहाँ दोनों conditions एक साथ true होनी जरूरी हैं, क्योंकि and का इस्तेमाल हुआ है।

Python Elif — जब Options दो से ज्यादा हों

असली programs में अक्सर सिर्फ दो नहीं, कई possibilities होती हैं। जैसे marks के आधार पर grade तय करना:

  • 90 या ज्यादा → Excellent
  • 75 या ज्यादा → Very Good
  • 60 या ज्यादा → Good
  • 33 या ज्यादा → Pass
  • इससे कम → Fail

बार-बार अलग-अलग if लिखने की बजाय, यहाँ elif (यानी "else if") काम आता है।

marks = 82

if marks >= 90:
    print("Excellent")
elif marks >= 75:
    print("Very Good")
elif marks >= 60:
    print("Good")
elif marks >= 33:
    print("Pass")
else:
    print("Fail")

Output:
Very Good

Python ऊपर से नीचे की तरफ conditions check करता जाता है, और जैसे ही कोई condition true मिलती है, उसका block चलाकर बाकी सारी conditions skip कर देता है।

If Elif Else — तीनों को एक साथ इस्तेमाल करना

if condition1:
    # code
elif condition2:
    # code
elif condition3:
    # code
else:
    # code

Example — Weather Check

temperature = 35

if temperature >= 40:
    print("बहुत ज्यादा गर्मी है")
elif temperature >= 30:
    print("गर्मी है")
elif temperature >= 20:
    print("मौसम ठीक है")
else:
    print("ठंड है")

Output:
गर्मी है

Practical Example — Even या Odd Number Check

number = 8

if number % 2 == 0:
    print("Even Number")
else:
    print("Odd Number")

Output:
Even Number

यहाँ % modulus operator है — अगर number को 2 से divide करने पर remainder 0 बचे, तो number even होता है।

User Input के साथ If Else

अब तक हमने fixed values के साथ conditions देखीं। लेकिन real programs में value अक्सर user से ही ली जाती है।

age = int(input("अपनी age enter करें: "))

if age >= 18:
    print("आप Adult हैं")
else:
    print("आप Minor हैं")

अगर user 20 enter करता है, तो output आएगा — आप Adult हैं।

अगर आपने अभी तक input() function ठीक से नहीं समझा, तो Python Input and Output वाली पोस्ट (यहाँ अपनी existing Input/Output पोस्ट का लिंक डालें) एक बार जरूर पढ़ लें।

Conditional Statements कहाँ-कहाँ इस्तेमाल होते हैं?

ये सिर्फ किताबी examples नहीं हैं — असली projects में इनका इस्तेमाल हर जगह होता है:

1. Login System

if password == correct_password:
    print("Login")
else:
    print("Invalid Password")

2. Age Verification

if age >= 18:
    print("Allowed")
else:
    print("Not Allowed")

3. Result System

if marks >= 33:
    print("Pass")
else:
    print("Fail")

4. Discount System

if amount >= 5000:
    print("20% Discount")
elif amount >= 2000:
    print("10% Discount")
else:
    print("No Discount")

Nested If — एक If के अंदर दूसरा If

कभी-कभी एक if के अंदर दूसरा if भी लिखना पड़ता है, इसे nested if कहते हैं।

age = 20
has_id = True

if age >= 18:
    if has_id:
        print("Entry Allowed")
    else:
        print("ID Required")
else:
    print("Age is too low")

Output:
Entry Allowed

Indentation क्यों इतनी जरूरी है?

Python में indentation सिर्फ style नहीं, बल्कि syntax का हिस्सा है। Python इसी से पहचानता है कि कौन सा code किस block के अंदर आता है।

गलत तरीका:

if age >= 18:
print("Adult")

सही तरीका:

if age >= 18:
    print("Adult")

Beginners जो Common गलतियाँ करते हैं

1. Colon भूल जाना — if age >= 18: में colon लगाना न भूलें।

2. = और == को confuse करना — = value assign करता है, == दो values compare करता है।

age = 18          # assignment
if age == 18:     # comparison
    print("Age is 18")

3. गलत Indentation — Python में हर block properly indent होना चाहिए, वरना IndentationError आ जाता है।

4. Condition उल्टी लिखना

# गलत
if marks < 33:
    print("Pass")

# सही
if marks >= 33:
    print("Pass")

and, or, not — Multiple Conditions को जोड़ना

and — दोनों conditions true होनी चाहिए:

if age >= 18 and marks >= 50:
    print("Eligible")

or — कम से कम एक condition true होनी चाहिए:

if day == "Sunday" or day == "Saturday":
    print("Weekend")

not — condition के result को उल्टा कर देता है:

if not logged_in:
    print("Please Login")

खुद Practice करें — कुछ Questions

  1. एक program बनाइए जो check करे कि number positive है या negative।
  2. एक program बनाइए जो check करे कि number even है या odd।
  3. Student के marks लेकर Pass या Fail print करें।
  4. Age के आधार पर Minor या Adult print करें।
  5. Marks के आधार पर Grade निकालें (90+ → A, 75+ → B, 60+ → C, 33+ → D, बाकी → F)
  6. Shopping amount के आधार पर discount calculate करें।

📥 इस पूरे गाइड को PDF में डाउनलोड करें

If, Elif aur Else Conditions पूरा नोट्स अपने पास सुरक्षित रखें और बिना इंटरनेट के भी पढ़ें।

PDF डाउनलोड करें

इन questions को खुद code करके देखें — सिर्फ पढ़ने से नहीं, practice से ही if-else पक्का होता है।

आगे क्या पढ़ें?

अगर आप Python शुरुआत से सीख रहे हैं, तो concepts को एक sequence में पढ़ना ज्यादा आसान रहता है — पहले basic syntax और variables, फिर data types और operators, और उसके बाद conditional statements और loops।

पूरी learning path के लिए Python Tutorial in Hindi देख सकते हैं। इसके अलावा Python Data Types , Python Type Casting और Python Strings वाली पोस्ट्स भी इसी क्रम में पढ़ने लायक हैं।

(FAQs)

Python If Else क्या है?

Python If Else एक conditional structure है, जिसका इस्तेमाल किसी condition के true या false होने के आधार पर अलग-अलग code execute करने के लिए किया जाता है।

Python में if statement क्या है?

if statement किसी एक condition को check करता है। अगर वह condition true होती है, तभी उसके अंदर लिखा code execute होता है।

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

elif का मतलब है "else if"। इसका इस्तेमाल तब होता है जब हमें एक साथ कई conditions check करनी हों।

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

जब if और सभी elif conditions false हो जाती हैं, तभी else वाला block execute होता है।

क्या Python में एक साथ कई elif इस्तेमाल कर सकते हैं?

हाँ, जरूरत के अनुसार एक if के बाद जितनी चाहें उतनी elif conditions लगाई जा सकती हैं।

Python में if और elif में क्या फर्क है?

if सबसे पहली condition check करता है, जबकि elif तभी अगली condition check करता है जब उससे पहले वाली condition false हो चुकी हो।

Python में = और == में क्या अंतर है?

= का इस्तेमाल किसी variable में value assign करने के लिए होता है, जबकि == दो values की equality check करने के लिए इस्तेमाल होता है।

Related Posts

🧑‍💻 Python Coding Lab

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