The fourth week of class notes 1th

  1. Function   keyword def

  The function name in parentheses  is the calling function

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. Return

  After completion of the function is equivalent to administration of another operator returns the value

 

It returns a tuple

If you return after return did not write none

  

 

 

 

 

Return the function may be a function of the entire operation of the rear end of the code is not running

 

 

 

 

  1. Function parameters

   

 

 

6. When execution of the function argument

Position parameters, A and i corresponding to b and j corresponding to      

To-one correspondence

 

 

 

Keyword arguments:

A variable value corresponding to a

Variables to be consistent

 

 

 

Mixing parameters:

There are positional parameters and keyword arguments

Keyword arguments must be in front of the location parameters

 

 

 

 

  1. Parameter     when a function defined  default parameters

     

     

If a variable is equal to a value called the default parameter values ​​can not pass

Results for the traditional values of 10

 

 

 

Pass value may not be given a default value, the result is 20

 Positional parameters

 

 

 

Dynamic parameters    when the number of parameters from time to time

* Args parameter with the position corresponding to the position of the extra parameters in the argument (the upper side when the function has parameters of this argument)

Parameter corresponding to the position in excess keyword arguments with parameters ** kwargs (when there are parameters for this function upper argument)

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/peiw/p/11872267.html