A comment allows you to write notes in your spoken language
Use the # symbol for single-line comments.
Everything after # on that line is ignored by Python.
Python does not have a specific syntax for multi-line comments, but you can use a series of # symbols or triple-quoted strings
You can comment multiple lines by adding # at the beginning of each line.
You can use triple quotes (''' or """) to write what looks like a multi-line comment, although it's actually a string (often used for documentation).
If it's not assigned to a variable or used as a docstring, Python will ignore it, effectively acting like a comment.
Docstrings are special kinds of comments used for documentation purposes in functions, classes, and modules. They're written using triple quotes (''' or """) and are used to describe what the code does.
Docstrings are different from comments because they can be accessed programmatically (e.g., with help()).
Take a quick look at this. You should be able to answer WHY COMMENTING IS IMPORTANT
Take a quick look at this. You should be able to answer WHY COMMENTING IS MAY BE a bad idea
Create a NEW file called: CH02_02a.py
We will create a header comment file which will be used for all of our programs:
#==========================================================
# Name:
# Date:
# Program:
# Description:
# Notes:
#==========================================================
Add THIS code to the CH02.02B.py file
Once you've done that, properly comment the file any way you see fit
You have to find a balance of overcommenting as well as undercommenting
Now... Add the following code to the CH02_02c.py file
Rewrite the program with comments, and nice formatting, so that a new programmer would be able to figure out what this does.
You MAY HAVE TO LOOK SOME OF THESE THINGS UP!!!
HINT:
Type these things in line by line and run it. You'll see exactly what this does. If you can figure it out by running, instead of looking it up, it would be WAY MORE FUN!!!
Create CH02_02d.py
Now... Add the following code to the CH02_02d.py file
Mark this program up with bad comments. Not fake weird things, but actual comments which are true, but may make this program unreadable or not efficient
Create CH02_02e.py
Now... Rewrite the program so it does NOT require comments and is readable. What does this even mean?
Change Variable Names to be more descriptive
Reorder Code
Use ABSOLUTE MINIMUM number of comments