forked from kal179/Beginners_Python_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcartesian_plane_quadrant.py
More file actions
21 lines (19 loc) · 585 Bytes
/
cartesian_plane_quadrant.py
File metadata and controls
21 lines (19 loc) · 585 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# quadrant determiner
# I(+,+) II(-,+) III(-,-) IV(+,-)
def determine_quadrant(x, y):
try:
if x > 0 and y > 0:
return 'I(+,+)'
elif x < 0 and y > 0:
return 'II(-,+)'
elif x < 0 and y < 0 :
return 'III(-,-)'
elif x > 0 and y < 0 :
return 'IV(+,-)'
else :
return 'Invalid parameters were provided')
except TypeError:
return "X and Y co-ords must be integers and not X {}, Y{}".format(type(x), type(y))
# Test
result = determine_quadrant(float(input('X co-ordinate: ')), float(input('Y co-ordinate: ')))
print("Quadrant is " + result)