一、函数
1、定义
"""
def 函数名([参数列表】):
['''文档字符串''']
函数体
[return语句]
"""
# 1、定义
def add():
result = 11 + 22
print(result)
def add_2(a,b):
result = a + b
print(result)
def add_3(a,b):
result = a + b
print(result)
return result
# c = a 函数内参数不能在外部使用
2、调用练习
调用:函数定义以后不会运行,调用才会运行
# 2、调用练习
# 函数定义以后不会运行,调用才会运行
add()
add_2(a=5,b=9)
add_2(10,1)
add_2(b=10,a=2)
re3 = add_3(10,3)
二、嵌套扩展
def add_modify(a,b):
result = a + b
print(result)
def test():
print("我是内层函数")
test()
add_modify(10,20)