# Test module for generating points at which a dart lands # assuming a 2x2 square centered at 0 # Asks for number of points (assumes ***no*** error checking!) # # Matt Bishop, MHI 289I, Winter 2018 # 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() # how many tosses should we show? n = int(raw_input("[NUMBER ONLY!!!] 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()