Comments in Python
General non-excutable instruction that are part of source code are called comments. Approximately all programming languages provide feature of comments. In python python programming hash (#) operator/symbol is used for writing some comment lines in the code. After typeing # the next string of characters will be treated as comment in python language.
Comment Syntax
Comment line is written by starting it with # character. In following example first line is comment.
# Displaying Hello World
print("Hello World")
Uses of Comment in python
Such like other high level programming languages, python has also some common uses of comments such as:
- It provide description about identfiers (Such as variable constants or methods)
- It make source code more readable.
- It is also used to provide developer/organization detail.
- It does not increase the size of source code.
- It can be place anywhere in the source code.
Type of Commetns
Python only support single line comments starting with #, but we can also add multiline comment by using # at the start of each line.
Python multiline comment example
#This is Multiline
#comment consist of
#three lines
print("Multiline comment example")