In [1]:
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display,Math
In [2]:
def angle_convert_plot():
    angle = eval(input('What angle to convert? '))
    unit = input('Which unit did you input (radian or degree)? ')
    
    if unit[0].lower()=='r':
        rad = angle
        deg = np.rad2deg(angle)
    elif unit[0].lower()=='d':
        deg = angle
        rad = np.deg2rad(angle)
    else:
        raise ValueError('Unknown unit!')
        
    deg = deg%360
    rad = rad%(2*np.pi)
    
    print(deg,rad)
    plt.plot([0,1],[0,0],'r',linewidth=2)
    plt.plot([0,np.cos(rad)],[0,np.sin(rad)],'r',linewidth=3)
    plt.axis('square') # 1st, order is important!
    plt.axis([-1,1,-1,1]) # 2nd, order is important!
    plt.grid()
    plt.title('Angle is %s$^o$ or %s rad.' %(deg,rad))
    plt.show()
In [3]:
angle_convert_plot()
What angle to convert? 1234123
Which unit did you input (radian or degree)? d
43 0.7504915783562467