# 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, ECS 36A, Winter 2019 # 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 = int(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()) # # go! # main()