上一页 1 ··· 3 4 5 6 7 8 9 10 下一页
  2024年10月28日
摘要: ` f=lambda x,y,z :xyz L=lambda x:[x2,x3,x**4] print(f(3,4,5));print(L(2)) print("学号:3005") ` 阅读全文
posted @ 2024-10-28 11:48 VVV1 阅读(12) 评论(0) 推荐(0)
摘要: ` def bifurcate_by(L,fn): return [[x for x in L if fn(x)], [x for x in L if not fn(x)]] s = bifurcate_by(['beep','boop','foo','bar'],lambda x:x[0]=='b 阅读全文
posted @ 2024-10-28 11:48 VVV1 阅读(19) 评论(0) 推荐(0)
摘要: 2.12.1 ` def factorial(n): r=1 while n>1: r*=n n-=1 return r def fib(n): a,b=1,1 while a<n: print(a,end=" ") a,b=b,a+b print('%d!=%d'%(5,factorial(5)) 阅读全文
posted @ 2024-10-28 11:47 VVV1 阅读(27) 评论(0) 推荐(0)
摘要: 2.11.1 ` import string import random x=string.ascii_letters+string.digits y=''.join([random.choice(x) for i in range(1000)]) d=dict() for ch in y: d[c 阅读全文
posted @ 2024-10-28 11:45 VVV1 阅读(19) 评论(0) 推荐(0)
摘要: `Dict={'age':18,'score':[98,97],'name':'Zhang','sex':'male'} for item in Dict: print(item) print(" ") for item in Dict.items(): print(item) print(" ") 阅读全文
posted @ 2024-10-28 11:44 VVV1 阅读(11) 评论(0) 推荐(0)
摘要: `Dict={'age':18,'score':[98,97],'name':'Zhang','sex':'male'} print(Dict['age']) #输出18 print(Dict.get('age')) #输出18 print(Dict.get('address','Not Exist 阅读全文
posted @ 2024-10-28 11:43 VVV1 阅读(12) 评论(0) 推荐(0)
摘要: ` dict1={'Alice':'123','Beth':'456','Cecil':'abc'} print(dict1['Alice']) dict1['new']='Hello' dict1['Alice']='1234' dict2={'abc':123,456:78.9} print(d 阅读全文
posted @ 2024-10-28 11:42 VVV1 阅读(8) 评论(0) 推荐(0)
摘要: ` student = {'Tom','Jim','Mary','Tom','Jack','Rose'} print(student) a=set('abcdabc') print(a) print("学号:3005") ` 阅读全文
posted @ 2024-10-28 11:42 VVV1 阅读(9) 评论(0) 推荐(0)
摘要: ` T=('abc',12,3.45,'Python',2.789) print(T) print(T[-1]) print(T[1:3]) print("学号:3005") ` 阅读全文
posted @ 2024-10-28 11:41 VVV1 阅读(34) 评论(0) 推荐(0)
摘要: import os fn=[filename for filename in os.listdir('D:/python xuexi/python work/数学建模课/!/《Python数学建模算法与应用》程序和数据/《Python数学建模算法与应用》程序和数据/02第2章 Python使用入门' 阅读全文
posted @ 2024-10-28 11:40 VVV1 阅读(12) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页