table of Contents
Twenty-six of the nested function
A nested function definition
- Internal function defined functions can not be used outside the function. (Only one function that it belongs to or deeper call)
form cmath import pi # 3.14
def circle(r,action):
if action == 'p':
def perimeter(): #周长
res = 2*pi*r
elif action == 'a':
def area():
res = pi*r**2
else:
res = 'error'
return res
Second, the nested function calls
def max(x, y):
if x > y:
return x
else:
return y
def max1(a, b, c, d):
res1 = max2(a, b)
res2 = max2(res1, c)
res3 = max2(res2, d)
return res3
max1(20,59,100,0)