top of page

Python Comments

Comments are short statements use to explain the code. We use symbol

to comment the line in python

 

Comments Benefits

  • Explain the logic behind the code

  • Stop code execution

  • Code Readability

  • Provide Hints for other developer

  • Solutions for future reference

​

Types of Comments

When we want to comment a single line we can use single line comment.

Single Line Comments

Single Line Comments

#Below code is for addition of two numbers

a = 5

b = 10

c = a + b

print(c)

Multi Line Comments

When we want to comment more than one line we can use multi line comments.

Multi Line Comments Using # symbol

#Below code is for addition of two numbers

#a = 5

#b = 10

#c = a + b

#print(c)

Multi Line Comments Using String literal

"""

Below code is for addition of two numbers

a = 5

b = 10

c = a + b

print(c)

"""

bottom of page