nerdexam
Python_Institute

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…

PEP and Best Practices

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)
  • B
    95% (42)
  • C
    2% (1)
  • D
    2% (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

#PEP 8#binary operators#line breaks#code style

Community Discussion

No community discussion yet for this question.

Full PCPP-32-101 Practice