摘要:
s1 = [str(x) + str(y) for x,y in zip(['v'] * 4,range(1,5))] s2 = list(zip('abcd',range(4))) print(s1);print(s2) print("3008") 结果如下图所示 阅读全文
posted @ 2024-10-15 17:24
方~~
阅读(20)
评论(0)
推荐(0)
摘要:
def filter_non_unique(L): return [item for item in L if L.count(item) == 1] a = filter_non_unique([1,2,2,3,4,4,5]) print(a) print("学号:3008") 结果如下图所示 阅读全文
posted @ 2024-10-15 17:23
方~~
阅读(8)
评论(0)
推荐(0)
摘要:
a = filter(lambda x:x > 10,[1,111,2,45,7,6,13]) b = filter(lambda x:x.isalnum(),['abc','xy12','***']) #isalnum()是测试是否为字母或数字的方法 print(list(a));print(li 阅读全文
posted @ 2024-10-15 17:22
方~~
阅读(34)
评论(0)
推荐(0)
摘要:
import random x = random.randint(1e5,1e8) y = list(map(int,str(x))) z = list(map(lambda x,y:x%2 == 1and y % 2 == 0,[1,3,2,4,1],[3,2,1,2])) print(x);pr 阅读全文
posted @ 2024-10-15 17:21
方~~
阅读(24)
评论(0)
推荐(0)
摘要:
x1 = "abcde" x2 = list(enumerate(x1)) for ind,ch in enumerate(x1):print(ch) print("学号:3008") 结果如下图 阅读全文
posted @ 2024-10-15 17:20
方~~
阅读(20)
评论(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( 阅读全文
posted @ 2024-10-15 17:19
方~~
阅读(24)
评论(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'%(6,factor 阅读全文
posted @ 2024-10-15 17:18
方~~
阅读(10)
评论(0)
推荐(0)
摘要:
from math import * a = sin(3) b = pi c = e d = radians(180) print(a);print(b);print(c);print(d) print("学号:3008") 结果如下图 阅读全文
posted @ 2024-10-15 17:13
方~~
阅读(9)
评论(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) print("学号:3008") 结果如下图 阅读全文
posted @ 2024-10-15 17:11
方~~
阅读(9)
评论(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) p 阅读全文
posted @ 2024-10-15 17:10
方~~
阅读(9)
评论(0)
推荐(0)