Find Position of a Cartesian Point in Python
Enter x: 2
Enter y: 3
Quadrant I
------------------------
Enter x: 0
Enter y: 6
Positive Y-axis
def main():
"""
Finds the quadrant of a Cartesian point.
"""
x = int(input("Enter x: "))
y = int(input("Enter y: "))
location = ""
if x == 0:
if y == 0:
location = "Origin"
elif y > 0:
location = "Positive Y-axis"
elif y < 0:
location = "Negative Y-axis"
elif x > 0:
if y == 0:
location = "Positive X-axis"
elif y > 0:
location = "Quadrant I"
elif y < 0:
location = "Quadrant IV"
elif x < 0:
if y == 0:
location = "Negative X-axis"
elif y > 0:
location = "Quadrant II"
elif y < 0:
location = "Quadrant III"
print(location)
if __name__ == "__main__":
main()