PDA

View Full Version : How to generate a random number in Python?



vittorio
06-04-2010, 01:08 PM
Hi All
someone can give an example of how to generate a random number in Python?
Ciao Vittorio

Steve Baer
06-04-2010, 03:32 PM
Hi Vittorio,
Use the random module that is part of the python standard library (http://docs.python.org/library/random.html)


import random
print random.random()
print random.random()

vittorio
06-04-2010, 07:46 PM
thanks for the quick response
Ciao Vittorio