Comments are one of the best ways of ensuring that you write quality code that can be easily understood.
Comments should explain the purpose of a section of code.
Most languages have two types of comment a single line comment and a multiple line comment.
In Python we use the # symbol to start a single line comment.
All text written after this symbol to the end of the line will not be processed as code by the program.
# A single line comment that takes up the entire line age = 5 # A variable to store the age
A multiple line comment is uses the “”” and “”” to start and end the comment
""" This is a multiple line comment You can put detailed instructions and information here. Such as the authors details Or the algorithm used. """
Always make sure that you fully document your code.
The more you comment your code the easier it is to understand and maintain.
You might remember what you are working on right now, but what happens when someone else looks at your code or you come back to it a week, month or a year later?