第1个回答 2022-03-22
建一个数组
100,102,104,...,200
随机生成 1-50 的数,作为 下标,指向 对应的偶数 就行
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import random
x = range(100,201,2)
i = 0
while i<=50:
index = random.randint(1,50)
print("%d -> %d" % (index,x[index]))
i += 1
#("Hello, World!")
结果: 部分
1 -> 102
1 -> 102
15 -> 130
13 -> 126
49 -> 198
4 -> 108
30 -> 160
45 -> 190