[Tutor] Random Numbers

Rob Andrews Rob Andrews" <rob@jam.rr.com
Tue, 3 Apr 2001 16:43:07 -0500


A quick reference for random stuff in Python is the Python Library
Reference:

http://www.python.org/doc/current/lib/module-whrandom.html
http://www.python.org/doc/current/lib/module-random.html

Here's a really terse example:

>>> import whrandom
>>> doh = whrandom.randint(1, 10)
>>> dog = whrandom.randint(1, 10)
>>> doh
5
>>> dog
7

Someone less newbie-like than I am can likely explain them better, but I
think this should do it. There are some source examples on Useless Python
(http://www.lowerstandard.com/python/pythonsource.html) that demonstrate a
few other things that may be done randomly in Python.

Rob

> How does one generate random numbers in python? Say from 1-10 for example?
>
> Thanks!
> Corey
>
> p.s. I'm still having focus() problems with my texteditor if anyone read
> those posts :(
>