Point Location on Axes

Take coordinates (x, y) and check if the point lies on the X-axis, Y-axis, or at the origin.

Logic BuildingAdvanced
Logic Building
# Take coordinates
x = float(input("Enter x coordinate: "))
y = float(input("Enter y coordinate: "))

# Check location
if x == 0 and y == 0:
    print("At origin")
elif x == 0:
    print("On Y-axis")
elif y == 0:
    print("On X-axis")
else:
    print("Not on any axis")

Output

Enter x coordinate: 0
Enter y coordinate: 0
At origin

Enter x coordinate: 0
Enter y coordinate: 5
On Y-axis

Enter x coordinate: 3
Enter y coordinate: 0
On X-axis

Check for zero coordinates to determine axis location.

Key Concepts:

  • Origin: both x and y are 0
  • Y-axis: x is 0, y is not 0
  • X-axis: y is 0, x is not 0
  • Check origin first, then axes