Python Tutorial

Python Syntax और Basic Structure

Chapter 3: Python Syntax और Basic Structure हिंदी में विस्तार से उदाहरणों और Placeholder Images के साथ। अंत में 20 MCQs और Quiz दिए गए हैं।


📘 Chapter 3: Python Syntax और Basic Structure (Python का वाक्य-विन्यास और मूल संरचना)

🔰 इस Chapter में आप जानेंगे:


🧾 Python Syntax क्या है?

Python का Syntax सरल और पढ़ने में आसान है। इसका वाक्य-विन्यास अन्य Programming Languages की तुलना में कम जटिल है।

Python Code का सबसे महत्वपूर्ण हिस्सा है – Indentation।

[Add Image Here – Python syntax structure diagram]


🧱 Python Code Structure की मूल बातें

✅ 1. Indentation (जगह छोड़ना)

Python में Block बनाना Indentation पर निर्भर करता है। कोई भी Function, Loop या Condition सही तरीके से चलाने के लिए Line के शुरुआत में Spaces जरूरी होते हैं।

उदाहरण:

if 5 > 2:
    print("5 बड़ा है 2 से")

❌ अगर आप Indentation नहीं देंगे तो Error आएगा।


✅ 2. Comments (टिप्पणियाँ)

Comments को Code में Notes की तरह लिखा जाता है, जो Execution में नहीं आते।

# यह एक Comment है
print("Hello")  # यह भी Comment है

✅ 3. Variables (चर)

Python में Variables को Declare करते समय Type बताने की ज़रूरत नहीं होती।

x = 5
name = "Amit"

Python एक Dynamically Typed Language है।


✅ 4. Statements (वाक्य)

Python में हर एक Line एक Statement होती है। Multiple statements एक ही लाइन में ; से भी लिखे जा सकते हैं:

x = 10; y = 20; print(x + y)

✅ 5. Case Sensitivity

Python में Variable और Keywords Case-Sensitive होते हैं:

name = "Amit"
Name = "Raj"

print(name)  # Output: Amit
print(Name)  # Output: Raj

📥 Input और 📤 Output

✅ Output – print() का उपयोग:

print("Welcome to Python")

✅ Input – input() का उपयोग:

name = input("अपना नाम दर्ज करें: ")
print("नमस्ते", name)

[Add Image Here – Input/output terminal example]


🔄 Multiline Statement

Python में लंबी Statements को \ का प्रयोग करके अगली Line में ले जा सकते हैं:

total = 1 + 2 + 3 + \
        4 + 5 + 6

🧠 निष्कर्ष