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 [0.0, 1.0).

The Python tool for converting float to integer is the int function.

However int(random.random() ) will always return 0.

In what range do you want the integers to fall?

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to