whileTrue:
try:
x = float(input("Enter the X axis coordonate =>"))
print(type(x))
break
except ValueError:
print('Please try again')
whileTrue:
try:
y = float(input("Enter the Y axis coordonate =>"))
print(type(y))
break
except ValueError:
print('Please try again')
cartesian = [x, y]
print('The input coordinate is:')
print('=>', cartesian)
note that the function WHILE allows you to enter the code into a cycle that checks the input until it is a variable that can be converted to a float, in this way you can work with negative numbers.
First, you have to import the math package, it’ll allow you to use the trigonometric functions, be aware that these functions work with radiants values, in this case, the code is written to print the angle in grades.
import math
size = (x**2 + y**2)**0.5
angle = math.atan(y / x) * 180 / math.pi
polar = [size, angle]
if x > 0and y > 0:
print('The coordonate isin the first quarter')
result = f'{size}, {angle}°'
print(result)
elif x < 0and y > 0:
print('The coordonate isin the second quarter')
result = f'{size}, {180-angle*-1}°'
print(result)
elif x < 0and y < 0:
print('The coordonate isin the third quarter')
result = f'{size}, {180+angle}°'
print(result)
elif x > 0and y < 0:
print('The coordonate isin the forth quarter')
result = f'{size}, {360-angle*-1}°'
print(result)
thanks to those who take the time to see my post… keep learning