Python Tutorials - Comments in Python, How to Create Comments in Python, How to create Multiline Comments in Python


Comments in Python, How to Create Comments in Python, How to create Multiline Comments in Python


The Comments are the very important part of a programming language to give the explanation of a particular code for future reference and the Python is one of them, Comments in Python are denoted with the pound or hash mark (#).When that is the first character of a line of code, the entire line is deemed a comment.The # can also appear in the middle of the line; this means from the point where it is found, the rest of the same line is a comment. For example:

single line Comments

# this entire line is a comment

shoo = 1

# short comment: assign int 1 to 'shoo'

print 'Python and %s are used to develop the web applications these are number %d' % ('Django', shoo)



Multiline Commets

The multiline comments achieved in python with the help of """ for example

"""This is ..

Multiline....

Comments.... """

Comments are not only used to explain nearby code, but also to prevent what would otherwise be working code from executing. and these are also used to help in maintenance of the software in future. 

{ 0 comments... read them below or add one }

Post a Comment