day10 finishing
Function ---- "tool
Function does not change a single function, it only does one thing -------> package (Interface), make the code more concise
Defined functions
def function name ():
"" "The description of the function" ""
Block
Wherein the function definition: function definition procedure, only detect syntax, the code is not performed
Three forms of function
Empty function
There are function parameters
No-argument function
------ call "function using the function
gues()
Address print (gues) function
Function's return value
A value is returned, but also a set of values (all data types)
return characteristics:
- return returns a return value, if no value is returned, return None
- Did not return a default return None
- return function terminates, the following code is not running, assuming a plurality of return when a return run of
- return separated by commas, you can return multiple values, return values received in the form of a tuple
Function parameters
There are function parameters: the parameters have their own property
: Followed by a predetermined data type of the parameter, prescriptive
-> the predetermined value followed by a return data type, the convention
Parameter: product-defined function stage, having received argument function, has the meaning described
Location parameter: receiving sequentially from left to right at the arguments
Default parameter: If not specified, the default value, if the value of call when traditional values, using the transmission, the default parameter in a position after the parameter
Argument: call phase product, is passed to a particular parameter values (all data types may be)
Argument position: left to right, to the position of the parameter value passed
Keyword arguments: the name of the parameter according to the parameter values transfer, argument must position in front of the keyword arguments
Vararg
The variable length parameter
* Lt, all pass over all arguments received and stored in the form of a tuple
Variable-length argument
lt = [1,2,3]
* The lt lt element within a passed parameter a is taken out