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
Tasks
-
Define an adequately named
Enum
class that automatically enumerates the seasons (Spring
,Summer
,Fall
, andWinter
). -
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 thechoice()
function to choose a random element from a collection.
Get hands-on with 1400+ tech skills courses.