Arrange a source file for predictable navigation

A team uses source-file organization, the arrangement of a file's sections, to help readers locate information. Arrange the Python blocks from top to bottom according to the team's documented layout:

  • The file description is the first statement, so Python recognizes it as the module's docstring.
  • Imports come before configuration constants.
  • All configuration constants come before function definitions.
  • The launch guard comes last, after the function it calls has been defined.

Each item below represents one complete block. Apply the stated team convention as well as the execution requirements.

  1. 1.

    from datetime import date

  2. 2.

    def display_summary(): print(REPORT_LABEL, date.today().isoformat())

  3. 3.

    REPORT_LABEL = "Room reservations"

  4. 4.

    """Display today's room reservations."""

  5. 5.

    if __name__ == "__main__": display_summary()

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Program Readability, Organization, and Documentation Questions: