If you need to generate a random number between two (2) numbers in Python, then you can make use of the random
module.
First, import the module:
Then you can use it like this:
Another option is to use randrange
and uniform
as follows:
1
2
3
4
5
6
7

from random import randrange, uniform
# randrange gives you an integral value
irand = randrange(0, 10)
# uniform gives you a floatingpoint value
frand = uniform(0, 10)
