The correct answers are C and D. PEP 8 recommends surrounding top-level function and class definitions with two blank lines. This improves readability by clearly separating major program units in a module. Inside a class, method definitions should be separated by a single blank line because methods are more closely related and need less visual separation than top-level definitions. Option A is incorrect because imports are commonly grouped into standard library imports, third-party imports, and local application imports, with blank lines separating those groups. Option B is incorrect because one blank line is insufficient for top-level functions and classes under PEP 8. These spacing rules support clean, predictable, maintainable Python code layout.
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit