Re: [Tutor] When I print random.random

2011-01-15 Thread Emile van Sebille
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

Re: [Tutor] When I print random.random

2011-01-14 Thread bob gailer
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.

Re: [Tutor] When I print random.random

2011-01-14 Thread Steven D'Aprano
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

Re: [Tutor] When I print random.random

2011-01-14 Thread Wayne Werner
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

Re: [Tutor] When I print random.random

2011-01-14 Thread bob gailer
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