import random
x = int(input('Enter a number for x: ')) --随机数最小值
y = int(input('Enter a number for y: ')) --随机数最大值
n = int(input('How many numbers do you want to create? ')) --生成几个随机数
for i in range(1, n+1):
z = random.randint(x, y)
print(z)
运行结果:
>>> import random
>>> x = int(input('Enter a number for x: '))
Enter a number for x: 1
>>> y = int(input('Enter a number for y: '))
Enter a number for y: 100
>>> n = int(input('How many numbers do you want to create? '))
How many numbers do you want to create? 7
>>> for i in range(1, n+1):
z = random.randint(x, y)
print(z)
93
82
48
13
14
83
96
>>>