Python: Typs of Argument

Programming languages allow controlling the ordering and default values of arguments. In python we will observe the following in different cases:

Case 1: Positional

This is default way of specifying arguments. In this, the order, count and type of actual arguments should exactly match that of the formal arguments. Else it will result error.

Python: Positional Argument

Case 2: Keyword

This allow flexibility in the order of passing the actual arguments by mentioning the argument name.

Python : Keyword in argument

Case 3: Default

This allows the specify default value for an argument in the function signature. It is used only when no value is passed for the arguments else it works normally. In Python, default arguments should be last in the order.

Python: Default Argument

Case 4: Variable argument count

This allows a function to have variable number of arguments. In Python, any argument name starting with ‘*’ is considered to be a vary length argument. It should be last in order, It works by copying all values beyond that position in a tuple.

Python: Variable argument count