def funcOpt(r, n=12):

From the previous excercise, we discussed that inside the parentheses your argument list can have:
  • no argument
  • one argument
  • as many arguments as you like/need.

    But moreover, lets say we want the argument list to have a default value. Meaning for the variable n. If you did not enter a value than n would be set to 12. Otherwise it would be set to what ever you enter it to be. In this case you just enter the variable n inside the function to be (n=12) def funcOpt(r, n=12):.

    Note that you can call funcOpt with a value of n or without.
  • funcOpt(1)
  • funcOpt(1, n=6)
    Arguments like n with default values specified are called Keyword arguments and they can be easily omitted by the use when user calls the function. for example funcOpt(1) is you want n to be 12.

    If you want n to be something else. For example (n=6) than you call it as funcOpt(1,n=6).

    The normal arguments are called positional arguments . Positional arguments have to appear before any keyword arguments. When the function is called, the positional argument must be supplied to the function in the same order as specified in the function definition.

    The keyword arguments, if supplied, can be supplied in any order providing they are supplied with their keywords. If supplied without their keywords, they too must be supplied in the order they appear in the function definition.

  • funcOpt(1,n=6)
  • funcOpt(1,6)