September 2013
Intermediate to advanced
350 pages
9h 38m
English
Programs can be quite complicated and are often thousands of lines long. It can be helpful to write a comment describing parts of the code so that when you or someone else reads it they don’t have to spend much time figuring out why the code is there.
In Python, any time the # character is encountered, Python will ignore the rest of the line. This allows you to write English sentences:
| | >>> # Python ignores this sentence because of the # symbol. |
The # symbol does not have to be the first character on the line; it can appear at the end of a statement:
| | >>> (212 - 32) * 5 / 9 # Convert 212 degrees Fahrenheit to Celsius. |
| | 100.0 |
Notice that the comment doesn’t describe how Python works. Instead, ...
Read now
Unlock full access