Exercise 1: A Well-Documented Function with Enums

Write a function that returns a random object.

We'll cover the following

Problem statement

This chapter explains how to choose proper names for classes, functions, and variables, how to document a function, and how to derive custom enumerated classes


  • Define an adequately named Enum class that automatically enumerates the seasons (Spring, Summer, Fall, and Winter).

  • Write an adequately named and documented function that returns a random season. The season must be a member of the previously defined class.

Test the function by calling it several times.

Note: The random module has the choice() function to choose a random element from a collection.

Get hands-on with 1200+ tech skills courses.