Comments are helpful in any programming. It helps to create hints for the certain way of coding in a programming script. Comments have no influence or impact on any part of coding. And it is purely meant as reading text in any scripting code page.
Single line Comment
If you are familiar with any other programming language then keep in mind, in python single line commenting is purely different.
Any single sentence if begins with # then that is a single line comment.
#Following codes determines the age of the employer
In the above example, the first sentence that begins with # is an example of single line comment. And it has no influence or impact on the python script. It is purely meant for reading purpose only. It hints coder the purpose of following codes.
If more than one sentence is wrapped between triple single quote then those sentences in python are known as multiline comments.
Following codes determines the age of the employer
For this first we need to fetch employee id
Then we need to fetch date of birth
Then by calling age calculator function we can get the age of the employee.
As the name says, more than one comment in the programming code.
Why do we need to include comments in a python script?
Suppose you are working in a project in a company. You have written the codes in the python script with certain logic. And lets say after six months, you are required to revisit the same python script and make changes because of a client’s demand. Then in such case there are 100% chances you may have forgotten why you have written the codes that way. So if you have written detailed hint in the form of comments, then later on when you revisit it will help you to quickly understand your code of block.