python basics (function 2)

The return value return

return [value] a plurality of values, comma-separated, there is no return value, none will return value, the function does not return a value to the specified value will be returned none

def functionname(p1,p2,p3):

  return value1,value2....

result = functionname(value1,value2,value3)

 

Scope of a variable is the area code to access the variable, if beyond the region, an error occurs when you visit.

Local variables

Function is only valid within the defined internal functions.

Global Variables

Function can be used in vivo and in vitro function

golbal keywords can be converted into local variables global variables

golbal local variable names

 

Anonymous function

lambda expressions

r = 10

result =lambda r:math.pi*r*r

print(trdult(r))

                                   There can be multiple or may not appear for while, etc.

 result = lambda[arg1[arg2,.....,argn]]:expression

 

 

Guess you like

Origin www.cnblogs.com/zhangjiantaocs/p/11899765.html