Write a program that reads the coordinates of a point (x, y) and determines in which quadrant the point lies.
Example 1:
Input: (3, 4)
Output: "Quadrant 1"
Example 2:
Input: (-3, -4)
Output: "Quadrant 3"
Remember, if both x and y are positive, the point lies in the first quadrant.
def find_quadrant(coords):
x, y = coords
if x > 0 and y > 0:
return “Quadrant 1”
elif x < 0 and y > 0:
return “Quadrant 2”
elif x < 0 and y < 0:
return “Quadrant 3”
elif x > 0 and y < 0:
return “Quadrant 4”
else:
return “On an axis”
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.