1 li=[34,12,33,1] 2 print(li) 3 for i in range(0,len(li)): 4 #range开始0 结束len(i)-1 5 for j in range(1,len(li)-i): 6 if li[j] < li[j-1] :#当前位置比前一个位置则互换位置 7 temp = li[j] 8 li[j] = li [j-1] 9 li[j-1] =temp 10 print(li)
1 count = 1 #计数器 2 def f(a1,a2): 3 global count 4 count +=1 5 print(a1)#打印波菲特数 6 if count > 10: 7 return 8 a3 = a1 + a2 9 f(a2,a3) 10 f(0,1)
1 def f(depth,a1, a2): 2 if depth ==10: 3 return a1 4 a3 = a1 + a2 5 r=f(depth+1,a2, a3) 6 return r 7 ret=f(1,0,1) 8 print(ret)