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.
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.
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
...
Log in to ExamTopics
Sign in:
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.
w_w_w_w_w_w
Highly Voted 1 year, 4 months ago2211094
Most Recent 4 weeks, 1 day agorafles
1 year, 4 months ago