摘要:
f = lambda x, y, z: x * y * z L = lambda x: [x2, x3, x**4] print(f(3, 4, 5)); print(L(2)) 阅读全文
posted @ 2024-10-27 23:16
世梦
阅读(11)
评论(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] 阅读全文
posted @ 2024-10-27 23:15
世梦
阅读(16)
评论(0)
推荐(0)
摘要:
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'%( 阅读全文
posted @ 2024-10-27 23:14
世梦
阅读(12)
评论(0)
推荐(0)
摘要:
import string, random, collections x = string.ascii_letters + string.digits y = ' '.join([random.choice(x) for i in range(1000)]) count = collections. 阅读全文
posted @ 2024-10-27 23:13
世梦
阅读(13)
评论(0)
推荐(0)
摘要:
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-27 23:11
世梦
阅读(27)
评论(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) p 阅读全文
posted @ 2024-10-27 23:10
世梦
阅读(18)
评论(0)
推荐(0)
摘要:
Dict = {'age': 18, 'score': [98, 97], 'name': 'zhang', 'sex': 'male'} try: print(Dict['age']) print(Dict.get('age')) print(Dict.get('address', 'Not Ex 阅读全文
posted @ 2024-10-27 23:08
世梦
阅读(48)
评论(0)
推荐(0)
摘要:
dict1 = {'Alice': '123', 'Beth': '456', 'Cecil': 'abc'} print(dict1['Alice']) dict1['new'] = 'Hello' dict1['Alice'] = '1234' dict2 = {'abc': 123, 456: 阅读全文
posted @ 2024-10-27 23:07
世梦
阅读(15)
评论(0)
推荐(0)
摘要:
student = {'Tom', 'Jim', 'Mary', 'Tom', 'Jack', 'Rose'} print(student) a = set('abcdabc') print(a) 阅读全文
posted @ 2024-10-27 23:06
世梦
阅读(19)
评论(0)
推荐(0)
摘要:
T = ('abc', 12, 3.45, 'python', 2.789) print(T) print(T[-1]) print(T[1:3]) 阅读全文
posted @ 2024-10-27 23:05
世梦
阅读(19)
评论(0)
推荐(0)

浙公网安备 33010602011771号