LPTHW – Exercise 2: Comments and Pound Characters

LPTHW Learn Python The Hard Way

Study Drills – 2
1. Find out if you were right about what the # character does and make sure you know
what it’s called (octothorpe or pound character).

The octothorpe or pound character tells Python that the line is going to be a comment. Code after a pound character will not be run by Python power shell.

1 # A comment, this is so you can read your program later.
2 # Anything after the # is ignored by python.
4 print "I could have code like this." # and the comment after is ignored
6 # You can also use a comment to "disable" or comment out a piece of code:
7 # print "This won't run."
9 print "This will run."
2. Take your ex2.py file and review each line going backward. Start at the last line, and
check each word in reverse against what you should have typed.

No Mistakes

3. Did you find more mistakes? Fix them.

No Mistakes

4. Read what you typed previously out loud, including saying each character by its name.
Did you find more mistakes? Fix them.



Previous exercise ⇐LPTHW – Exercise 1: A Good First Program