# Test module to see if a point is within the unit circle # Points are assumed to be in rectangle (-1, -1) and (+1, +1) # ECS 10, May 11, 2009 # Matt Bishop # if x^2 + y^2 <= 1, they are in the unit circle def inunitcircle(x, y): return x ** 2 + y ** 2 <= 1 # main routine to enable us to test gettoss() def main(): # get co-ordinates x, y = input("x, y co-ordinates separated by comma: ") # generate that many in the obvious way while -1 <= x and x <= 1: # print each one out print "(%f,%f) are" % (x, y), # announce result if inunitcircle(x, y): print "in", else: print "not in", print "the unit circle" # get co-ordinates x, y = input("x, y co-ordinates separated by comma: ") main()