1、作用域
def change_name(name):
print ("before change ",name) name = 'kaka' print ("after change ",name)name = 'xiqiao'
change_name(name)print (name)----------------------------------------
结果:
before change xiqiao
after change kakaxiqiao2、递归
1)、递归必须有一个明确的退出条件
2)、每次进入更深一层递归时,问题规模相比上次递归都应减少;
3)、递归效率不高,递归层级过多时,会导致栈溢出.
def calc(n):
print (n) if int(n/2)>0: return calc(int(n/2)) print ("-->",n)calc(10)
3、高阶函数