Python Function | Python Variable Function Arguments

Python Variable Function Arguments

Up until now, functions had a fixed number of arguments. In Python, there are other ways to define a function that can take a variable number of arguments.
Three different forms of this type are described below.

• Python Default Arguments
• Python Keyword Arguments
• Python Arbitrary Arguments

Python Default Arguments

Python has a different way of representing syntax and default values for function arguments. Default values indicate that the function argument will take that value if no argument value is passed during the function call.

The default value is assigned by using the assignment(=) operator of the form keywordname=value.

Python Keyword Arguments

Normally When we call a function with some values, these values get assigned to the arguments according to their position.

Python allows functions to be called using keyword arguments. When we call functions in this way, the order (position) of the arguments can be changed.

Python Arbitrary Arguments

Sometimes, we do not know in advance the number of arguments that will be passed into a function. Python allows us to handle this kind of situation through function calls with an arbitrary number of arguments.
In the function definition, we use an asterisk (*) before the parameter name to denote this kind of argument.