2024年10月28日
摘要: ` from random import sample from numpy.random import randint a=sample(range(10),5) b=randint(0,10,5) print(a);print(b) print("学号:3005") ` 阅读全文
posted @ 2024-10-28 11:50 VVV1 阅读(2) 评论(0) 推荐(0) 编辑
摘要: ` import math import random import numpy.random as nr a=math.gcd(12,21) b=random.randint(0,2) c=nr.randint(0,2,(4,3)) print(a);print(b);print(c) print 阅读全文
posted @ 2024-10-28 11:49 VVV1 阅读(1) 评论(0) 推荐(0) 编辑
摘要: ` 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 阅读(4) 评论(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 阅读(1) 评论(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 阅读(1) 评论(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 阅读(2) 评论(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 阅读(1) 评论(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 阅读(3) 评论(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 阅读(1) 评论(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 阅读(1) 评论(0) 推荐(0) 编辑