新手,等一个解答
2.2 用randint()方法生成取值范围为、长度为20的随机元组randTuple,并按从小到大的顺序排序对该元组进行排序,最后打印输出所有元素。 为什么不是列表? from random import randintrandTuple = tuple(sorted(randint(0, 100) for _ in range(20)))
print(randTuple) import random
d = []
while len(d) < 20:
x = random . randint(0 , 100)
if x not in d:
d . append(x)
d . sort()
print(tuple(d)) jackz007 发表于 2020-3-11 17:29
谢谢,
zltzlt 发表于 2020-3-11 17:25
谢谢
页:
[1]