[Tutor] When I print random.random
bob gailer
bgailer at gmail.com
Sat Jan 15 04:25:00 CET 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110114/288a6631/attachment.html>
More information about the Tutor
mailing list