Python Comments

In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters. Python Comments

There are two types of comment lines in python

  1. Single line comment
  2. Multi-line comments

1.Single line comment : 

To comment a single line ,we use single line comment i.e. hash tag (#).

a = 5  # This is single line comment 
print(a) 
# output should be 5
5

Note: Comments are ignored by the interpreter during the execution of the program.

2.Multi-line comments: 

To comment multiple lines, we use multi-line comment ,we write the text (comments) in triple double quotes (“““ ”””)or triple single quotes(‘’’ ’’’).

#This is 
#Multi-line
#comment
print("Hello World!")
Hello World

Example 2:

"""
This is 
Multi-line
Comment
"""
print("Hello World!")
Hello World

Advantages :

  1. Easy to understand.
  2. Code Readability.
  3. Explanation of the code or project.

Python Comments
  1. comment is a programmer-readable explanation or annotation in the source code of a computer program.
  2. There are two types of comment lines in python
    • Single line comment
    • Multi-line comments