
Table of Contents All Chapters 1. Dunder Methods 2. Commonly Used Dunder Methods Python Tutorial Python Introduction Identation &...
python मे Identation & Comments एक basic syntex का part है इसको जाने बिना कोई भी programmer, python मे coding नहीं कर सकता……
python के code में indentation देना बहुत ही जरूरी होता है, इससे code के structure समझने में आसानी होती है और बिना indentation से code में error भी आ सकता है।
indentation को देने के लिए हम tab या 4 space का use करते हैं। Generally code editor में indentation देने की जरूरत नहीं होती यह automatic दे देता है, but ना दे तो हम tab button को press करके दे सकते हैं। नीचे दिए गए syntax में आप indentation को अच्छे से समझ सकते हैं।
def example(name):
if name:
print(f"Hello, {name}!")
else:
print("Hello, World!")
example("Alice")
यहां पर पहले line का code तो start से लिखा है but दूसरी line में हमने कुछ space दिया है इसी को indentation कहते हैं.
जब हम code editor में code लिखते हैं तो उसका execution होता है but हम चाहते हैं कि इसमें कुछ लाइन ऐसी लिखी हो जिसका execution ना हो तो हम comment का use करते हैं, यह लाइन सिर्फ code को समझने के लिए लिखी जाती है। python में 2 type के comments होते हैं।
जब हम एक ही लाइन में comment देना चाहते हैं तो single line comment का use करते हैं। इसके लिए # press करके कुछ भी लिखते हैं तो यह एग्जीक्यूट नहीं होता है।
जब हमें एक से ज्यादा लाइन में comment लिखना होतो हम multi line comment का use करते हैं, इसके लिए triple quotes ( ‘‘‘ or “““ ) का use करते हैं।
नीचे syntax में single line comment और multi line comment को अच्छे से समझ सकते हैं.
# This is a single-line comment
print("Hello, Programmer") # This is an inline comment
"""
This is a multi-line comment
It can span multiple lines
"""
print("Hello, Programmer")
उम्मीद करते है कि आपको python मे Identation & Comments का use समझ मे या गया होगा । अपने learning को continue रखने के लिए next button पर click करे,
Table of Contents All Chapters 1. Dunder Methods 2. Commonly Used Dunder Methods Python Tutorial Python Introduction Identation &...
Table of Contents All Chapters 1. Encapsulation 2. Access Modifiers 2.1. Public Members 2.2. Protected Members...
Table of Contents All Chapters 1. Lambda Function 2. Nestesd Lambda Function 3. Lambda Function with if-else 4. Lanbda with...
Table of Contents All Chapters 1. Nested Function 2. Return Function from Function 3. Higher Order Function 4. Function Recursion...
Table of Contents All Chapters 1. Parameters and Aguments 2. Function Parameters 2.1. *args 2.2. **kwargs...
Table of Contents All Chapters 1. Context Manager 2. with Statement 2.1. __enter__() Method 2.2. __exit__()...
Table of Contents All Chapters 1. Error Handling 2. Types of Error 2.1. Syntax Error 2.2....
Table of Contents All Chapters 1. File Pointer 2. File Pointer Methods 2.1. tell() Method 2.2....
Table of Contents All Chapters 1. File Handling 2. Types of File 3. open() and close() Methods 4. File Modes...