[Tutor] FW: (no subject)

Luke Paireepinart lukepdev at gmail.com
Sun Dec 2 00:19:46 CET 2012


Ashfaq,


On Sat, Dec 1, 2012 at 10:46 AM, Ashfaq <quazi.ashfaq at gmail.com> wrote:

> Run your code 10,000 times. :)
>
>
> ** **
>>
>> import math****
>>
>> import random****
>>
>> random.seed()****
>>
>>
> there is no need to call seed() with no parameters.  From the docs:
""" If *x* is omitted or None, current system time is used; current system
time is also used to initialize the generator when the module is first
imported."""

So you see when you"import random" the random number generator will seed
automatically with the system time.



points = []
> for i in range(0, 10000):
>
>     x=random.uniform(0,1)
>
>     y=random.uniform(0,1)
>
>     points.append ( (x, y) )
>

Also you could use a generator for all these lines,
points = [(random.uniform(0,1), random.uniform(0,1)) for i in range(10000)]

-Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121201/02c196ca/attachment.html>


More information about the Tutor mailing list