# _*_ coding: utf-8 _*_
# 函数的嵌套调用:在一个函数内部有调用其他函数
# 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))
# 4
# 函数的嵌套定义:在函数内又定义了其他函数
# def func():
# def foo():
# print('from foo')
# print(foo)
# # <function func.<locals>.foo at 0x10fe8bb70>
# foo()
# # from foo
# x = 1
# print(x)
#
# func()
# 通过嵌套定义函数求圆的周长或面积
# from math import pi
# def circle(radius,action): # 第一个参数输入半径,第二个参数控制输出的嵌套的函数
# def cal_perimeter():
# return 2*pi*radius
#
# def cal_area():
# return pi * (radius**2)
#
# if action == 1: # 控制输出周长还是面积
# res = cal_perimeter()
# elif action == 2:
# res=cal_area()
# return res
#
# res = circle(10,2)
# print(res)