python Keyword argument code example

Example 1: python keyword arguments

#in python, arguments can be used using keywords
#the format is:
def function(arg,kwarg='default'):
    return [arg,kwarg]

Example 2: python positional argument

A function definition may look like:

def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):
      -----------    ----------     ----------
        |             |                  |
        |        Positional or keyword   |
        |                                - Keyword only
         -- Positional only

where / and * are optional.
If used, these symbols indicate the kind of parameter by how
the arguments may be passed to the function:
      positional-only, positional-or-keyword, and keyword-only.
Keyword parameters are also referred to as named parameters.