python

14 阅读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、调用练习
#函数定义以后不会运行,调用才会运行
add()
add_2(a=5,b=9)
add_2(10,1)
add_2(b=10,a=2)

re3 = add_3(10,3)