Ad Code

Responsive Advertisement

Comments in Python | Learn Python for free

Comments in Python | Learn Python for free 

What are comments in Python | Why are comments used in Python | What is the use of Comments in Python | Python tutorials For free | Multi-line Comments in Python



 

Comments in Python


What are Comments?

Comments are the statements in a script that are ignored by the python interpreter and therefore, have no effect on the actual output of the code.

Comments make the code more readable and understandable for human beings.

 

This makes the revision / modification of the code easier by the original author of the code and also by you if you are given the responsibility.

Comments are not necessary in a script , but these are highly recommended if the script is too complex or if it is to be reviewed by multiple people over an interval of time.

 
A comment in Python starts with a hash symbol ( # ) anywhere in a line and extends till the end of the line . The following code contains two single line comments:


# this is a line comment
x=10
y=x+100    # value of x+100 is assigned to variable y
print(y)


Multi-line comments -:

What are Multi line Comments?


Multi-line Comments are the comments which are written in multiple lines . they are written in two types, you can see them in the below image -:




The multi-line comments are also written by using three quotes above and below the line.
For example-:


Question For you -:

Fill in the blank




Comment below for the answer



For any query comment in the comment box we are here for you all the time.





Post a Comment

0 Comments