摘要:
s1 = [str(x) for x, y in zip(['v'] * 4, range(1, 5))] s2 = list(zip('abcd', range(4))) print(s1); print(s2) 阅读全文
posted @ 2024-10-27 23:25
世梦
阅读(15)
评论(0)
推荐(0)
摘要:
def filter_non_unique(L): return [item for item in L if L.count(item) == 1] a = filter_non_unique([1, 2, 3, 4, 5]) print(a) 阅读全文
posted @ 2024-10-27 23:24
世梦
阅读(24)
评论(0)
推荐(0)
摘要:
a = filter(lambda x: x > 10, [1, 11, 2, 45, 7, 6, 13]) b = filter(lambda x: x.isalnum(), ['abc', 'xy12', '***']) print(list(a)); print(list(b)) 阅读全文
posted @ 2024-10-27 23:23
世梦
阅读(26)
评论(0)
推荐(0)
摘要:
import random x = random.randint(1e5, 1e8) y = list(map(int, str(x))) z = list(map(lambda x, y: x%2 == 1 and y%2 == 0, [1, 3, 2, 4, 1], [3, 2,1, 2])) 阅读全文
posted @ 2024-10-27 23:22
世梦
阅读(14)
评论(0)
推荐(0)
摘要:
x1 = "abcde" x2 = list(enumerate(x1)) for ind, ch in enumerate(x1): print(ch) 阅读全文
posted @ 2024-10-27 23:21
世梦
阅读(32)
评论(0)
推荐(0)
摘要:
import numpy.random as nr x1 = list(range(9,21)) nr.shuffle(x1) x2 = sorted(x1) x3 = sorted(x1, reverse=True) x4 = sorted(x1, key = lambda item: len(s 阅读全文
posted @ 2024-10-27 23:20
世梦
阅读(24)
评论(0)
推荐(0)
摘要:
from ex2_12_2 import * print(factorial(6)) fib(300) 阅读全文
posted @ 2024-10-27 23:19
世梦
阅读(19)
评论(0)
推荐(0)
摘要:
from math import * a = sin(3) b = pi c = e d = radians(180) print(a); print(b); print(c); print(d) 阅读全文
posted @ 2024-10-27 23:19
世梦
阅读(17)
评论(0)
推荐(0)
摘要:
from random import sample from numpy.random import randint a = sample(range(10), 5) b = randint(0, 10, 5) print(a); print(b) 阅读全文
posted @ 2024-10-27 23:18
世梦
阅读(19)
评论(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)) pr int(a); print(b); pr 阅读全文
posted @ 2024-10-27 23:17
世梦
阅读(21)
评论(0)
推荐(0)

浙公网安备 33010602011771号