摘要: #s=1!+2!+3!+…..+n! from functools import reduce def factorial(n): result=0 for i in range(1,n+1): result+=reduce(lambda x,y:x*y,list(range(1,i+1))) print('%s的阶乘加和结果为:%s'%(i,... 阅读全文
posted @ 2018-12-29 14:04 小金儿 阅读(675) 评论(0) 推荐(0) 编辑
摘要: #列表去重 #方法1: l = [1,2,5,2,2,6,5,6,6,1,2,8] print(l) #方法1: l = [1,2,5,2,2,6,5,6,6,1,2,8] l_new=[] for i in l: if i not in l_new: l_new.append(i) print('l_new',l_new,n) #方法2: l = [1,2,5,... 阅读全文
posted @ 2018-12-29 12:37 小金儿 阅读(152) 评论(0) 推荐(0) 编辑