random number including 1 - i.e. [0,1]
wuwei23 at gmail.com
Wed Jun 10 00:01:46 EDT 2009
On Jun 10, 11:32 am, John Yeung <gallium.arsen... at gmail.com> wrote:
> On Jun 9, 8:39 pm, Paul McGuire <pt... at 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.
More information about the Python-list