Discussion Forum | Board Infinity

What are arguments?

Arguments and types of Arguments.

A value passed to a function (or Method) when calling the function. There are two types of arguments:

  • keyword argument: an argument preceded by an identifier (e.g. name=) in a function call or passed as a value in a dictionary preceded by **. For example, 3 and 5 are both keyword arguments in the following calls to complex

· complex(real=3, imag=5)

· complex(**{‘real’: 3, ‘imag’: 5})

  • positional argument: an argument that is not a keyword argument. Positional arguments can appear at the beginning of an argument list and/or be passed as elements of an preceded by *. For example, 3 and 5 are both positional arguments in the following calls:

· complex(3, 5)

· complex(*(3, 5))

Arguments are assigned to the named local variables in a function body See the calls section for the rules governing this assignment. Syntactically, any expression can be used to represent an argument; the evaluated value is assigned to the local variable.