# Test module to see if a point is within the unit circle
# Points are assumed to be in rectangle (-1, -1) and (+1, +1)
# (i.e., ***no*** error checking!)
#
# Matt Bishop, MHI 289I, Winter 2018
#
# for point x, y, if x^2 + y^2 <= 1, they are in the unit circle
# parameters: x, y: co-ordinates of point
# returns True if so, False if not
def inunitcircle(x, y):
return x ** 2 + y ** 2 <= 1
# main routine to enable us to test gettoss()
#
# get co-ordinates
x = float(raw_input("[Number only; < -1 or > 1 quits] x co-ordinate: "))
y = float(raw_input("[Number only; < -1 or > 1 quits] y co-ordinate: "))
# generate that many in the obvious way
while -1 <= x and x <= 1:
# print each one out
print "(%f,%f) is" % (x, y),
# announce result
if inunitcircle(x, y):
print "in",
else:
print "not in",
print "the unit circle"
# get co-ordinates
x = float(input("[Number only; < -1 or > 1 quits] x co-ordinate: "))
y = float(input("[Number only; < -1 or > 1 quits] y co-ordinate: "))