Answer to Question #178814 in Python for Woyengimiesindo Malati

Question #178814

Write a program that prompts the user to input the x-y coordinate of a point in a Cartesian plane. The program should then output a message indicating whether the point is the origin, is located on the x- (or y-) axis, or appears in a particular quadrant.

Samples of expected output:

Enter x and y coordinates: 0 0

(0, 0) is the origin


Enter x and y coordinates: 4 0

(4, 0) is on the x-axis


Enter x and y coordinates: 0 -3

(0, -3) is on the y-axis


Enter x and y coordinates: -2 3

(-2, 3) is in the second quadrant


Enter x and y coordinates: 1 -4

(-2, 3) is in the fourth quadrant


1
Expert's answer
2021-04-08T02:58:33-0400
xy=input("Enterthe x-y coordinate of a point in a Cartesian plane. ").split(' ')
x=int(xy[0])
y=int(xy[1])
if x == 0 and y == 0:
    print(f"({x},{y}) is the origin")
elif y == 0:
    print(f"({x},{y}) is on the x-axis")
elif x == 0:
    print(f"({x},{y}) is on the y-axis")
elif y > 0:
    if x > 0:
        print(f"({x},{y}) is in the first quadrant")
    else:
        print(f"({x},{y}) is in the second quadrant")
else:
    if x < 0:
        print(f"({x},{y}) is in the third quadrant")
    else:
        print(f"({x},{y}) is in the fourth quadrant")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS