# Test module to see if a point is within the unit circle
# Points are assumed to be in rectangle (-1, -1) and (+1, +1)
#
# Matt Bishop, ECS 10, Fall 2012
#
# 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 = float(input("[Number only; < -1 or > 1 quits] x co-ordinate: "))
y = float(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),end=' ')
# announce result
if inunitcircle(x, y):
print("in", end=' ')
else:
print("not in", end=' ')
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: "))
main()