On 1/14/2011 9:19 PM Steven D'Aprano said...
walter weston wrote:
when I print random.random() it always returns a float why is this?
how do I change it to a whole number?
Because random.random() is defined to always return a float between 0
and 1. That's what it does.
If you want a random wh
Please always reply to the list, not just to me.
On 1/14/2011 10:42 PM, walter weston wrote:
I want a whole number thats 5 digits long, I want to use it as a
password and if I just type random.random() I get a long float.
random.randint(a, b)
Return a random integer N such that a <= N <= b.
walter weston wrote:
when I print random.random() it always returns a float why is this? how do I
change it to a whole number?
Because random.random() is defined to always return a float between 0
and 1. That's what it does.
If you want a random whole number, you can call random.randint or
On Fri, Jan 14, 2011 at 9:25 PM, bob gailer wrote:
> On 1/14/2011 10:02 PM, walter weston wrote:
>
> when I print random.random() it always returns a float why is this? how do
> I change it to a whole number?
>
>
> That depends on what behavior you want.
>
> If you RTFM you will see:
> random.r
On 1/14/2011 10:02 PM, walter weston wrote:
when I print random.random() it always returns a float why is this?
how do I change it to a whole number?
That depends on what behavior you want.
If you RTFM you will see:
random.random()
Return the next random floating point number in the range