Comments in Python

In this tutorial, we will learn about Comments in Python. Comments are not used to perform any function in the program but they really useful for developers. Developers can write comments with variables and functions to remember their working (purpose) in the program. One important thing to mention comments doesn’t put any impact on the execution of program because interpreter simply ignores them. There are two kinds of comments in Python:

  • Single-Line Comments
  • Multi-Line Comments

Single-Line Comments:

Single line comments are used to add one line comments with variable and functions. We id hash sign(#) to create a single-line comment in Python. Please check this example to understand it more wisely.

Example Program:

#This is sigle line comment
print("Welcome to Owlbuddy")

Multi-Line Comments:

The multi-line comments are used to write comments of more then one line in program. we have two options to add multi line comments in Python. First one is using hash sign(#) second one is triple quotes(”’).

Multi-Line Comments using #

#This is sigle line comment
#using hash sign
print("Welcome to Owlbuddy")

Multi-Line Comments using ”’

'''This is sigle line comment
#using hash sign'''
print("Welcome to Owlbuddy")

Here Triple Quote Comments are working because Python simply ignores all the string literal which are not assigned to any variable.

Spread the love
Scroll to Top