I am writing an algorithm which should be able to determine in which quadrant a radian is based on two values that the user inputs. I think that the code is calculating the radian but I know that those values are not being compared to the pi values that I gave since I am not getting any output.
Code below:
print('Enter the radians of the angle (a*π/b): ')
a = int(input('a value(top): '))
b = int(input('b value(bottom): '))
radians = ((a*math.pi)/b)
print('')
print('Finding...')
if radians > 0 and radians < (math.pi/2):
print(f'The angle {radians}rad is in the I quadrant')
if radians > (math.pi/2) and degrees < math.pi:
print(f'The angle {radians}rad is in the II quadrant')
if radians > math.pi and radians < (3*math.pi/2):
print(f'The angle {radians}rad is in the III quadrant')
if radians > (3*math.pi/2) and radians < (2*math.pi):
print(f'The angle {radians}rad is in the IV quadrant')
First of all, you should rename degree to radians. The other problem is that you are assumed that all inputs are between 0 and 2pi. You should consider other inputs.
import math
print('Enter the radians of the angle (a*π/b): ')
a = int(input('a value(top): '))
b = int(input('b value(bottom): '))
radians = ((a*math.pi)/b)
print('')
print('Finding...')
while radians > 2 * math.pi:
radians -= 2 * math.pi
while radians < 0:
radians += 2 * math.pi
if 0 < radians < (math.pi / 2):
print(f'The angle {radians}rad is in the I quadrant')
if (math.pi / 2) < radians < math.pi:
print(f'The angle {radians}rad is in the II quadrant')
if math.pi < radians < (3 * math.pi / 2):
print(f'The angle {radians}rad is in the III quadrant')
if (3 * math.pi / 2) < radians < (2 * math.pi):
print(f'The angle {radians}rad is in the IV quadrant')