When we define a function, we often have a need for optional parameters. This allows us to write functions which are more flexible, and can be used in more situations.
We can also think of this as a way to create a family of closely-related functions, each with a slightly different collection of parameters – called the signature – but all sharing the same simple name. The idea of many functions sharing the same name can be a bit confusing. Therefore, we'll focus more on the idea of optional parameters.
An example of optional parameters is the int() function. This has two forms:
- int(str): For example, the value of int('355') has a value of 355. In this case, we didn't provide a value for the optional base parameter; the default value of 10 was used.
- int(str, base): For example, the value of int(&apos...