Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCPP-32-101 All Questions

View all questions & answers for the PCPP-32-101 exam

Exam PCPP-32-101 topic 1 question 17 discussion

Actual exam question from Python Institute's PCPP-32-101
Question #: 17
Topic #: 1
[All PCPP-32-101 Questions]

Look at the following examples of comments and docstrings in Python Select the ones that are useful and compliant with PEP 8 recommendations. (Choose two.)

  • A.
  • B.
  • C.
  • D. price = price + 1 # Decrement price by one to compensate for loss.
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
w_w_w_w_w_w
Highly Voted 1 year, 4 months ago
Selected Answer: BC
B has an extra blank line, after the first description, as it should for a multiline comment. A has no extra line. They can't be both true. https://peps.python.org/pep-0257/#id17 The inline comment for D doesn't have the required two spaces, and the description doesn't match the code C seems to be some (obvious) documentation string.
upvoted 6 times
...
2211094
Most Recent 4 weeks, 1 day ago
BC are correct answers.
upvoted 1 times
...
rafles
1 year, 4 months ago
Selected Answer: AC
According to PEP 257: "Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description". This makes letter B incorrect. The issue with letter D is that it's saying the opposite of what is doing ("Decrease", but it's actually adding) Letter A is a good example of a docstring, and letter C is a block comment
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...