Thanks all. I needed to ask because I'm writing a couple of programs which require the computer to choose numbers at random thanks.
Nathan Pinno "Jeremy Jones" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Nathan Pinno wrote: > > > Hi all, > > > > Does Python have a random function? If so, can you show me an example > >using it? > > > > Thanks, > > Nathan Pinno > > http://www.npinnowebsite.ca/ > > > > > > > > > > > Take your pick: > > In [5]: import random > > In [6]: random.choice(range(10)) > Out[6]: 2 > > In [7]: random.choice(range(10)) > Out[7]: 7 > > In [8]: random.choice(range(10)) > Out[8]: 8 > > In [9]: random.choice(range(10)) > Out[9]: 8 > > > In [14]: random.random() > Out[14]: 0.56386154889489271 > > In [15]: random.random() > Out[15]: 0.47322827346926843 > > In [16]: random.random() > Out[16]: 0.39921336622176518 > > In [17]: random.random() > Out[17]: 0.65521407248459007 > > In [18]: random.random() > Out[18]: 0.74525381787627598 > In [20]: r = range(10) > > In [21]: random.shuffle(r) > > In [22]: r > Out[22]: [6, 4, 9, 7, 2, 0, 8, 3, 5, 1] > > > Jeremy Jones -- ---------------------------------------------------------------- Posted via UsenetRevolution.com - Revolutionary Usenet ** HIGH RETENTION ** Specializing in Large Binaries Downloads ** http://www.UsenetRevolution.com -- http://mail.python.org/mailman/listinfo/python-list