Comments are very essential part of program. If they are not included, it becomes difficult to troubleshoot bugs or another application engineer will find it difficult to understand the program.
Comments are non executable statement or they are ignore by complier. They are created for the purpose understanding the code.
There are two types of comments in Python. 1) Single Line Comment 2) Multiline Comment
Single Line Comment
Single line comment starts with # sign and the entire line till the end is considered as comment. Below are the examples
# Adding two numbers a = 10 # Assigning value to variable a
Entire first line is treated as comment. Second line starts with a statement of value assignment. After this statement # symbol indicates comments till the end of line. Only statement a = 10 will be executed by compiler while any statement after # symbol will be ignored by compiler.
Multiline comments are used to treat multiple lines as a comment. We can use # symbol to create multiline comments but not recommended. Below is the example.
#Program to know temperature of a refrigerator #Program using two functions #Program gets value from outside
Instead use triple single quotes or triple double quotes to indicate multiline comments.
Triple Single Quotes
'''Program to know temperature of a refrigerator #Program using two functions Program gets value from outside'''
Triple Double Quotes
"""Program to know temperature of a refrigerator #Program using two functions Program gets value from outside"""