[Tutor] FW: (no subject)

Ed Owens eowens0124 at gmx.com
Sat Dec 1 00:12:21 CET 2012


Hi, im trying to write a script which randomly generates 10,000 points(x,y)
in the unit square(so range between 0 and 1 for both x and y).

so far I have written the code below in red, however it only produces one
random point. How do I get it to repeat this so it produces 10,000 different
random points?

Thankyouuu, Tara.

 

import math

import random

random.seed()

 

x=random.uniform(0,1)

y=random.uniform(0,1)

 

-                      Doesn't the above just produce a single X and Y?

 

for i in range(0,1):

    for j in range(0,1):

        print (x,y)

 

-                      And this only gives a single I, and single j,
resulting in one 'print' execution.

 

If you want 10K points, then the point-generating statements (X=., Y=.)
needs to be enclosed in a loop that increments the number of times you want.
Where's that range(0,10000) loop?

 

Ed

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121130/0753934b/attachment-0001.html>


More information about the Tutor mailing list