前言
函数
print('hello')
def hello():
print('hello1')
print('hello2')
print('hello3')
hello()
def add():
num1 = 20
num2 = 30
result = num1 + num2
print('%d + %d = %d' %(num1,num2,result))
add()
def westos():
print('westos')
def python():
print('python')
python()
westos()
def welcome(a):
print('hello',a)
welcome('laoli')
welcome('laowang')
参数
参数:形参 实参
形参:位置参数 默认参数 可变参数 关键字参数
位置参数
def getInfo(name,age):
print(name,age)
getInfo('westos',11)
getInfo(11,'westos')
getInfo(age=11,name='westos')
默认参数
def mypow(x,y=2):
print(x**y)
mypow(4)
mypow(2,3)
可变参数
def mysum(*a)