Commenting in Python
Commenting is used in programming to show what sections of the code do. They are shown in different ways, in different programming languages. In Python, they are shown using a # character. They are basically a descriptive sentence or paragraph explaining what a segment of code (or the whole program) does.
Here is an example:
Imagine we have a procedure that says ‘hello’ and the user’s name. If we needed to write a comment to describe that procedure, it could look like this:
#This function would output hello alongside the user’s name
The comment would appear just above the procedure, so it would look like this:
#This function would output hello alongside the user’s name def welcome(name): print(“Hello ” + str(name))
Commenting is really important when you are writing code (or Pseudocode) because it helps whoever is reading your code understand what you are aiming to do. So don’t forget to add comments into your code from now on.