Pre-determined Arguments
We can set predetermined arguments when creating a functions to create versatility and complexity within our function.
Example: Distance between two points or the origin
Explanation
Notice that when we first define the function, the last two arguments are assigned with values; This is called predetermined arguments
In a scenario when the user of the function doesn’t set these arguments, the function itself gives value to the missing arguments
The predetermined arguments are changeable evidently by our first distance() function call
We can also explicitly set each individual argument by the name of the arguments from the function (see the 3rd function call)
Rules:
The required arguments (arguments without predetermined values) must be defined first in the function
The predetermined arguments must be then defined after
Last updated