random.randint(2, 12) returns same results every time it's run in Python

前端 未结 4 791
小鲜肉
小鲜肉 2020-12-12 01:00

I have a script that generates 10 random numbers between 2 and 12:

repetition = 10
while repetition > 0:
    print(random.randint(2,12))
    repetition =          


        
4条回答
  •  渐次进展
    2020-12-12 01:33

    #Try numpy:

    import numpy as np

    np.random.randint(low=1,high=7,size=10)

    #Mostlikely, it will give you different results after each run.

提交回复
热议问题