1. Definition
Formal parameters: When defining a function, the arguments in the function parentheses are called formal arguments
Features: Formal parameters can be interpreted as variable names
def my_func (x, y): #x, Y is the formal parameter
Print (x)
Print (y)
Arguments: When a function is called, the argument inside the function's parentheses is called an argument
Features: Arguments can be understood as variable values
My_func (#1), 2 is the argument
2. Understanding
Parameter (variable name) will be bound when called (variable value) argument
After the call is finished, unbind
3. Specific application
Positional parameters: Parameters defined in left-to-right order
Positional parameters: Required parameter
Positional arguments: Pass values to parameters by location
Keyword parameter: In the form of Key=value
Note: The keyword parameter must be placed behind the positional argument
and can only pass the value once
Default parameter: When a function is defined, it is already assigned a value, which means that it is not possible to pass a value at the call stage
Note: The default parameter must be placed after the position parameter
The default parameter is assigned only once in the definition phase, and only once
The value of the default parameter should be defined as an immutable type
Named keyword parameter: the parameter defined after * is called a named keyword argument and must be passed as a keyword argument