Quantcast
Viewing latest article 7
Browse Latest Browse All 10

Python comments

In this Python tutorial 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 comments multiple lines

In Python we can also use multi line comments.Python comments multiple lines 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

 

The post Python comments appeared first on ByteArray.

Viewing latest article 7
Browse Latest Browse All 10

Trending Articles