Randomizing in Python

Mark Nenadov mark at freelance-developer.com
Sat Mar 3 11:56:07 EST 2007


On Sat, 03 Mar 2007 08:46:09 -0800, andre.ditador9999 at gmail.com wrote:

>      I want to randomize a certain calculation in Python but haven't
> figured it out yet. To explain what i mean, I' m going to use an
> example:
>                         I want to get the numbers to do a random
> experience database for a game. What would be necessary to do so?


Look into the random module (http://docs.python.org/lib/module-random.html)

random.choice selects a random item out of a sequence
random.shuffle shuffles a sequence randomly
random.random gives a random floating point number

-- 
Mark Nenadov -> skype: marknenadov, web: http://www.marknenadov.com
-> "Relying on the government to protect your privacy is like asking a
peeping tom to install your window blinds." -- John Perry Barlow




More information about the Python-list mailing list