nerdexam
Python_Institute

PCEP-30-02 · Question #156

You develop a Python application for your company. You want to add notes to your code so other team members will understand it. What should you do?

The correct answer is B. Place the notes after the # sign on any line. In Python, the # character marks everything to its right on that line as a comment, which Python's interpreter ignores entirely - this is the standard, built-in mechanism for annotating code for human readers. Option A is wrong because placing notes after the last line of code…

Question

You develop a Python application for your company. You want to add notes to your code so other team members will understand it. What should you do?

Options

  • APlace the notes after the last list of code separated by a blank line.
  • BPlace the notes after the # sign on any line.
  • CPlace the notes inside of parentheses on any line.
  • DPlace the notes before the rst line of code separated by a blank line.

How the community answered

(44 responses)
  • A
    7% (3)
  • B
    73% (32)
  • C
    16% (7)
  • D
    5% (2)

Explanation

In Python, the # character marks everything to its right on that line as a comment, which Python's interpreter ignores entirely - this is the standard, built-in mechanism for annotating code for human readers. Option A is wrong because placing notes after the last line of code (separated by a blank line) is not valid Python syntax for comments - Python would try to interpret that text as code. Option C is wrong because parentheses are used for function calls, tuples, and grouping expressions, not for comments; text inside parentheses is treated as a string or expression. Option D is wrong for the same reason as A - plain text before your code without a # prefix is a syntax error unless it's a string literal. A helpful memory tip: think of # as the "hashtag for humans" - just like a hashtag labels content for a specific audience on social media, # labels a line of code as a note meant for people, not the interpreter.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice