Comments in Python

Comments in python or any language is very useful, as they provide us the details about the code and it’s a good practice to place the comments in your python code so that you can easily catch up with your code and understand what it’s doing or what for is’s written. In a large project it’s mandatory to use comments so other can also get what is the purpose of which code. 

Python supports two types of comments:

1) Single lined comment:

In case user wants to specify a single line comment, then comment must start with ?#?

Eg:

  • # This is single line comment used in python.  

 

2) Multi lined Comment:

Multi lined comment can be given inside triple quotes.

eg:

  • ”’ This
  •     Is
  •     Multipline comment
  • used up by us”’

 

 

eg for both types of comments:

  • #single line comment  
  • print “Hello Python”  
  • ”’This is 
  • multiline comment ”’