PCPP-32-101 · Question #21
Select the true statement about PEP 8 recommendations related to line breaks and binary operators.
The correct answer is B. It is permissible to use line breaks before or after a binary operator, as long as the convention is. Even though in Python you're allowed to break code lines before or after binary operators (providing you do so consistently and that this convention has been used in your code before), it is recommended that you follow Donald Knuth's style suggestions and break before binary…
Question
Select the true statement about PEP 8 recommendations related to line breaks and binary operators.
Options
- AIt is recommended that you use line breaks before binary operators to improve code readability
- BIt is permissible to use line breaks before or after a binary operator, as long as the convention is
- CIt is recommended that you use line breaks after binary operators to improve code readability
- DThere is no specific PEP 8 recommendation related to using line breaks with binary operators
How the community answered
(44 responses)- B95% (42)
- C2% (1)
- D2% (1)
Explanation
Even though in Python you're allowed to break code lines before or after binary operators (providing you do so consistently and that this convention has been used in your code before), it is recommended that you follow Donald Knuth's style suggestions and break before binary operators as this results in a more readable, eye-friendly code.
Topics
Community Discussion
No community discussion yet for this question.