How to Commenting in Python
Comments in Python are preceded by a hash symbol (#) on a line and called a line comment. Three consecutive single quotation marks''' are used to give multiple comments or comments on several lines at once and called paragraph comment.
When the Python interpreter sees #, it ignores all the text after # on the same line. Similarly, when it sees the triple quotation marks ''' it scans for the text ''' and ignores any text in between the triple quotation marks.
The following program demonstrates the use of comment statements in Python.
# Learn How to Comment in Python
print('I Learnt How to comment in Python')
''' Amazing tool
in python called comment'''
print('Bye')
Output
I Learnt How to comment in Python
Bye
Explanation: As explained above, Python ignores all the text in a statement if it is preceded by the # symbol. When the above program is executed, it ignores all the text followed by the # symbol and triple quotation marks.
Comments
Post a Comment