If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Comments program में line of code होता है जो कि execute नहीं होता है , जिससे कि जब दुबारा हम उस program पर काम करे तो हर step हमें समझ आ सके कि हमने इसमें किया क्या था। Comments single Line भी हो सकते है और Multi-line भी हो सकते हैं।
Python में Comments दो तरह के होते है -
single line comments को hash # की help से लिखते हैं - -
Example -
# single line comment print("Single Line comment");
single line comments को हम executable python code वाली line में भी लिख सकते हैं।
For Example-
#single line comment.
name = "Hello World !." #single line comment.
print(name)
C:\Users\Rahulkumar\Desktop\python>python comments.py Hello World !.
JavaScript या PHP की तरह इसमें single line comment को double slash // से नहीं लिख सकते हैं।
python में multi line comment लिखने के लिए हमें triple double quotes """ से start करते हैं और triple double quotes से ही """ # का use करके भी multiline comments लिख सकते हैं।
इसके अलावा आप triple single quotes का use करके ''' multiline comment ''' लिख सकते हैं।
#so like this.
#we can write multi
#line comments.
print("multi line comments.")
"""
so like this
we can write multi
line comments
"""
C:\Users\Rahulkumar\Desktop\python>python multiline_comment.py multi line comments.
Note- comment वाली line में हम कितना भी space छोड़े उससे कोई फर्क नहीं पड़ता है।
किसी भी project पर काम करने के बाद हमें जरूरत के हिसाब से समय के साथ उसमे changes करने पढ़ ही जाते हैं तो जब हम update करें तो हमें proper पता चले कि हमने किया क्या था।
या जब कोई दूसरा programmer हमारे द्वारा develop किये गए project को देखे या update करे तो उसे भी पता चले।
Comment लिखना आपकी Coding Standardization को भी बताता है।
Comments लिखने से Coding Readability भी बढ़ती है।
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook