Python comments

Here we will study that How to write Python comments. Comments are very special part of any programming language, They helps to understand the code. If comments are not written in programming code, then its hard to understand its functionality. It increases code readability.

Below we will study about comments with examples

Python Comments

 

Single line comment

Here we will study about python single line comment. Python single line comment are written with hash #. any character or word written after hash is consider as comment in Python.

 

Example of Python comment

var="Python tutorial for beginners"

#this is single line comment in Python  
print(var)

Output

Python tutorial for beginners

 

In above example, line written after # is treated as comment in Python, and Python will not take that line for executing the code.

 

Python Multi line comment

In Python we can also use multi line comments. Multi line comments are written with triple double quotes “””.

 

Example of multi line comments

var="Python tutorial for beginners"

"""
this is python multi line comments, 
Any thing written here will treated as comments in 
Python.
""" 
print(var)

Output

Python tutorial for beginners

 

Please follow and like us:
READ  Python If Statement | Python If-else Statement | Python elif Statement