Check your understanding of the previous reading on comments.

Question 1

Which of these are synonyms for Python's comment symbol #?

Select every option that applies, then check.

  • Correct. The reading calls # "the Octothorpe" — one of its traditional names.
  • Not quite. The exclamation mark is !, used for negation in some languages and shebang lines, not as a name for Python's comment symbol.
  • Not quite. A "sigil" is a general term for a symbolic prefix character (like $ in some languages) — it isn't one of the names the reading uses for # specifically.
  • Correct. The reading names # "the Hash symbol".
  • Not quite. A decorator is a Python feature written with @, unrelated to comments.
  • Not quite. A variable is a name that stores a value — it has nothing to do with the comment symbol.
  • Not quite. print is a function that displays output; it isn't a name for #.
  • Correct. The reading also calls # "the pound sign".

Question 2

What part of this line's code will be commented out?

a = 7#+3#+2

Show explanation

Python removes the # and everything after it, to the end of the line. The first # comes right after the 7, so #+3#+2 is commented out, the second # included. Only a = 7 actually runs.

Question 3

What part of this line's code will be commented out?

# 1/0

Show explanation

The # is the very first character on the line, so the entire line is commented out, 1/0 included. Nothing on this line executes, which is just as well, since 1/0 would otherwise raise a ZeroDivisionError.

Question 4

What part of this line's code will be commented out?

m = "#3" #4

Show explanation

The # inside the string literal "#3" does not count as a comment marker: comments inside string literals are the one exception the reading mentions. Only the second #, the one outside the string, starts a comment, so #4 is commented out.

Question 5

According to the reading's advice, which of these scenarios justifies leaving a comment in your program?

Select every option that applies, then check.

  • Not quite. This describes commenting out code without explaining why. The reading calls commenting-out code "generally bad practice" unless you also leave a comment explaining what the old code was for — silently commenting out broken code doesn't meet that bar.
  • Correct. This is exactly the reading's "reasonable middle ground": write comments for code that is unexpected or surprising, even after you've tried to make it clearer.
  • Not quite. The reading explicitly rejects this "extreme opinion" of commenting every single line.
  • Not quite. The reading also rejects this opposite extreme — comments are useful for explaining confusing code.
  • Not quite. The reading says "removing code using comments is generally bad practice," and its advice is to "remove any comments that don't help explain the existing code." Old code you no longer need is exactly that kind of comment, so the reading's advice is to remove it, not to leave it there.

Question 6

# Here is my program.

x = 12
# Do some math
y = x / 60 + .5
print(y)

1. How many non-blank lines does this program have?

2. How many steps will actually be executed when it runs?

Word bank — not all numbers are used