Generate random number between 0.1 and 1.0. Python

后端 未结 10 1680
南方客
南方客 2020-12-29 05:23

I\'m trying to generate a random number between 0.1 and 1.0. We can\'t use rand.randint because it returns integers. We have also tried random.uniform(0.1

10条回答
  •  孤城傲影
    2020-12-29 05:35

    In numpy, you can do the following:

    import numpy
    numpy.random.uniform(0.1, numpy.nextafter(1, 2))
    

提交回复
热议问题