Python program to find out the quadrant in which the given co-ordinate lie
Quadrant in which the given co-ordinate lie in Python
Here, in this page we will discuss the program to find the quadrant in which the given co-ordinate lie in python . From the origin at x = 0 and y = 0, a pointy can move in four different directions. There are 4 coordinates available when we think in 2-Dimension. These 2-dimensions are at X-axis and Y-axis. Now based on their positive or negative nature this axis shows 4 different quadrants. This 4-Quadrants are different and are as follows:-
- +X+Y where both the points are at positive X-axis and positive Y-axis so we call this as the First quadrant.
- -X+Y where one point lies at the negative X-axis and other at positive Y-axis so we call it the Second quadrant.
- -Y-X where both the points lie at negative X-axis and negative Y-axis so we call it the Third quadrant.
- -Y+X where one point is at the negative Y-axis and the other one is at positive X-axis so we call it the Fourth quadrant.
- Step 1:- Start.
- Step 2:- Take inputs for X and Y.
- Step 3:- Check if both X and y are positive Print First quadrant.
- Step 4:- Else if check X is negative and Y is positive print Second quadrant.
- Step 5:- Else if check X and Y both are negative print Third quadrant.
- Step 6:- Else if check X is positive and Y is negative print Fourth quadrant.
- Step 7:- Else print X and Y are at origin.
- Step 8:- End.
Code to find the Quadrant in which the given co-ordinate lie in python
#take inputs for X and Y X = int(input('Enter value for X-axis :')) Y = int(input('Enter value for Y-axis :')) #check for 1st quadrant if X > 0 and Y > 0: print('X and Y lie at First quadrant') #check for 2nd quadrant elif X < 0 and Y > 0: print('X and Y lie at Second quadrant') #check for 3rd quadrant elif X < 0 and Y < 0: print('X and Y lie at Third quadrant') #check for fourth quadrant elif X > 0 and Y < 0: print('X and Y lie at Fourth quadrant') else: print('X and Y lie at Origin')
Enter value for X-axis :24
Enter value for Y-axis :-14
X and Y lie at Fourth quadrant