#函数的嵌套分为两类:
# 1.函数的嵌套定义: 在函数内部又定义了一个函数
# def foo():
#     x=1
#     # print(x)
#     def bar():
#         print('from bar')
#
#     bar()
# foo()
# from math import pi
# 
# def circle(radius,types=0):
#     def perimiter(radius):
#         return 2 * pi * radius
# 
#     def area(radius):
#         return pi * (radius ** 2)
# 
#     if types == 0:
#         res=perimiter(radius)
#     elif types == 1:
#         res=area(radius)
#     else:
#         print('不支持的操作,types必须传入0或者1')
# 
#     return res
# circle(10,1)
# 2.函数的嵌套调用: 在调用一个函数的内部又调用其他函数
# def max2(x,y):
#     if x > y:
#         return x
#     else:
#         return y
#
# def max4(a,b,c,d):
#     res1=max2(a,b)
#     res2=max2(res1,c)
#     res3=max2(res2,d)
#     return res3
#
# print(max4(1,2,3,4))