1 Comments


Comments are one of the best ways of ensuring that you write quality code that can be easily understood.

Comments should explain[1] the purpose of a section of code.

Most languages have two types of comment[2] a single line comment and a multiple line comment.

In Python[3] 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?

Terms definitions
1. explain. “Explain” requires students to describe in detail the “what” and the “why”, in order to clarify information. This means to provide reasons for, to account for, to provide a clear answer, to clarify. Logical reasons are provided.
2. comment. Disabling a block of source code by changing it into a comment. This technique is used for debugging or for testing the functionality of alternative versions of code.
3. Python. A type of programming language. It is one of many high-level, general-purpose programming languages. It was first released in 1991