# 函数的嵌套调用:在一个函数内部调用另一个函数
def fn1():
pass
def fn2():
fn1() # 函数的嵌套调用
def fn3():
fn2() # 函数的嵌套调用
fn3()
# 案例:
# 求两个数最大值
def max_two(n1, n2):
if n1 > n2:
return n1
return n2
# 求三个数最大值
def max_three(n1, n2, n3):
max = max_two(n1, n2)
return max_two(max, n3)
# 求四个数最大值
def max_four(n1, n2, n3, n4):
max = max_three(n1, n2, n3)
return max_two(max, n4)
print(max_four(20, 50, 30, 50))