python中的函数能够大幅度的减少代码的冗余和内存的占用
1,函数语法格式:
def 函数名称([参数列表]): #缩进 函数体
#[ return 返回值]
例子:实现去绝对值的函数
def my_abs(x): if x >= 0: return x else: return -x print(my_abs(-99))
在函数中pass------等于占位符 2,参数(限制) 在python中函数的参数也有着相应的规则和应用限制 (1),如果设置函数时的参数个数与应用时的个数不能等会报错  (2),如果参数类型错误   3,返回多个值 ```python import math def move(x,y,step,angle=0): nx = x + step*math.cos(angle) ny = y - step*math.sin(angle) return nx,ny x,y = move(7,7,7,math.pi/6) print(x,y)
4,返回多个值的时候实际上是一个元组
import math
def move(x,y,step,angle=0): nx = x + step*math.cos(angle) ny = y - step*math.sin(angle) return nx,ny r = move(7,7,7,math.pi/6) print(r)



