I've tried both of these versions:
import random
def r(n):
random.seed(1234)
for i in range(n):
x=random.uniform(-1,1)
y=random.uniform(-1,1)
return (x,y)
import random
def r(n):
random.seed(1234)
while n>0:
n-=1
x=random.uniform(-1,1)
y=random.uniform(-1,1)
return (x,y)
But both only produce 1 point.
I'm hoping to make it produce n random points (x,y) and have it print out all n points.
returnstatement will finish yourr()function in the first iteration of theforloop. You can return all yournpoints from the function, as the previous answer informed. Or you can create a function that will return just a pair of points, and call it repeatedlyntimes.