# Test module for generating points at which a dart lands
# assuming a 2x2 square centered at 0
# ECS 10, May 11, 2009
# Matt Bishop
import random
# Generate a landing position for a dart tossed at
# a 2x2 square with center at (0,0)
# returns: (x, y) co-ordinates of toss
def gentoss():
x = 2*random.random() - 1
y = 2*random.random() - 1
return x, y
# main routine to enable us to test gettoss()
def main():
# how many tosses should we show?
n = input("Number of tosses to generate: ")
# generate that many in the obvious way
for i in range(n):
# print each one out
print "Co-ordinates of toss are: ", gentoss()
main()