# # point_explorer.py # # A client program for Point objects # # CS 111 # from point import * p1 = Point(7, 24) p2 = Point(0, -7) print('p1 has coordinates', p1) # calls __repr__ print('p2 has coordinates', p2) # calls __repr__ dist1 = p1.distance_from_origin() # need parens! dist2 = p2.distance_from_origin() # need parens! print(p1, 'is', dist1, 'units away from the origin') print(p2, 'is', dist2, 'units away from the origin') print('moving p1 down 7 units...') # We eliminate the assignment on the line that calls move_down(). # Because move_down() doesn't explicitly return a value, it returns None, # and we don't want to assign the None to p1. # In addition, no assignment is needed, because move_down() changes # the internals of p1. p1.move_down(7) print('p1 now has coordinates', p1) # New client code: # part a x = int(input('Enter an x-coordinate: ')) y = int(input('Enter a y-coordinate: ')) # part b p3 = Point(x, y) # part c print(p3, 'is', p3.distance_from_origin(), 'units from the origin') # part d p3.flip() print('after flipping p3, its coordinate are', p3) # part e p3_quad = p3.quadrant() if p3_quad == 0: print(p3, 'is on an axis') else: print(p3, 'is in quadrant', p3_quad)