1.

Python Comments

Answer»

Comments are lines of text/code in the program, which are ignored by the compiler during program execution.

There are multiple types of comments in python:

  • Inline Comment -

We can write an Inline Comment by typing # followed by the comment.

# Inline Comment to calculate sum of 2 numbers
def fun(a, b):
return a + b
  • Multiline Comment -

We can write a Multiline Comment by typing # followed by the comment in each of the lines.

# Multiline
# Comment
# Function to calculate
# sum of 2 numbers
def fun(a, b):
return a + b
  • Docstring Comment -

Docstring comments are achieved by Typing the comment within triple quotes. (''' comment ''')

'''
This is a function
to find sum
of 2 numbers.
This is an example of
docstring comment.
'''
def fun(a, b):
return a + b


Discussion

No Comment Found