3.2 Designing functions with optional parameters
When we define a function, we often have a need for optional parameters. This allows us to write functions that are more flexible and easier to read.
We can also think of this as a way to create a family of closely related functions. Each function has a slightly different collection of parameters – called the signature – but all sharing the same simple name. This is sometimes called an ”overloaded” function. Within the typing module, an @overload decorator can help create type hints in the more complicated cases.
An example of an optional parameter is the built-in int() function. This function has two signatures:
int(str) -> int. For example, the value of int(’355’) has a value of 355. An optional base parameter defaults to a value of 10.
int(str, base) -> int. For example, the value of int(’163’,&...