On Jun 10, 11:32 am, John Yeung <gallium.arsen...@gmail.com> wrote: > On Jun 9, 8:39 pm, Paul McGuire <pt...@austin.rr.com> wrote: > > Are you trying to generate a number in the > > range [0,n] by multiplying a random function that > > returns [0,1] * n? If so, then you want to do > > this using: int(random.random()*(n+1)) This will > > give equal chance of getting any number from 0 to n. > > Better still is simply > > random.randint(0, n)
There's a big difference between randint - which generates _integers_ in the range 0 & n - and the OPs request for generating random floating point values between & inclusive of 0 & n. -- http://mail.python.org/mailman/listinfo/python-list