Certified Professional in Python Programming (PCPP-32-101) — Question 26
Select the true statement about PEP 8 recommendations related to line breaks and binary operators.
Answer options
- A. It is recommended that you use line breaks before binary operators to improve code readability
- B. It is permissible to use line breaks before or after a binary operator, as long as the convention is consistent locally. However, for new code, it is recommended that break lines should be used only after binary operators.
- C. It is recommended that you use line breaks after binary operators to improve code readability
- D. There is no specific PEP 8 recommendation related to using line breaks with binary operators
Correct answer: A
Explanation
The correct answer, A, states that using line breaks before binary operators is recommended to enhance code readability, aligning with PEP 8 guidelines. Option B suggests flexibility that is not as strongly endorsed in PEP 8 for new code, while option C incorrectly states the recommendation is after binary operators. Option D entirely dismisses the existence of PEP 8 guidelines on this topic, which is inaccurate.