PYTHON4 functions: Global functions, local functions, lambda functions, methods
Many built-in functions
Syntax: def functionname (parameters):
Suite
Return is used to return the result object, which is optional: Returns multiple values separated by commas and grouped into tuples
Local variables, global variables, built-in variables
Global variable: Defining a Globals variable
Python's closures
Parameter passing form:
Position parameters: from left to right
Keyword parameters: matching by keyword name
Mix the above two ways: all positional parameters, all the keyword parameters
Use default parameters when defining functions: Parameters with default values
When mixing parameters with default and no default values, no default values are placed in front
Variable parameters: Parameters that start with * when defining a function, collect positional parameters, output tuple ()
When you define a function with a * * start, the phone keyword parameter, output dictionary {}
Variable parameter unpacking: When calling a function, use the * parameter, which can be used to scatter the parameter collection to pass any number of arguments based on the position or keyword
anonymous function lambda is an expression rather than a statement
Lambda Args:expression (args: A comma-separated variable)
Python function basics