1、冒泡排序
#!/usr/bin/env python# -*- coding:utf-8 -*-# 冒泡排序li = [12,34,2,4,1,6,5,78,46,34,65,18]for j in range(len(li)-2): for i in range(len(li)-1): if li[i] > li[i+1]: temp = li[i] li[i] = li[i+1] li[i+1] = temp print(li)
2、寻找斐波那契数列中特定的数
#!/usr/bin/env python# -*- coding:utf-8 -*-#递归求解斐波那契数列中的某一个数def f(depth,a1,a2): #print(depth) if depth == 10: return a1 a3 = a1 + a2 ret = f(depth + 1,a2,a3) return retret = f(1,0,1)print(ret)