Search code examples
pythonnumpyanglepiradians

How can I make an output in radians with pi in it?


I want to give out an angle in radians in python. I also know how to do that but is it posible to make the output like that 1 * pi instead of 3.14159 without programming it myself?

Thx for help.


Solution

  • Just like this (cf furas's comment) :

    from math import pi
    
    angle = 2*pi
    angle_new_format = angle/pi
    print("angle =", angle)
    print("angle_new_format = {} * pi".format(angle_new_format))
    

    Output :

    angle = 6.283185307179586
    angle_new_format = 2.0 * pi