How do you get radians in python?

❮ Math Methods


Example

Convert different degrees into radians:

# Import math Library
import math

# Convert different degrees into radians
print(math.radians(180))
print(math.radians(100.03))
print(math.radians(-20))

Try it Yourself »


Definition and Usage

The math.radians() method converts a degree value into radians.

Tip: See also math.degrees() to convert an angle from radians to degrees.


Syntax

Parameter Values

ParameterDescription
x Required. The degree value to be converted into radians. If the parameter is not a number, it returns a TypeError

Technical Details

Return Value:A float value, representing the radian value of an angle
Python Version:2.0

❮ Math Methods




Description

The radians() method converts angle x from degrees to radians.

Syntax

Following is the syntax for radians() method −

radians(x)

Note − This function is not accessible directly, so we need to import math module and then we need to call this function using math static object.

Parameters

x − This must be a numeric value.

Return Value

This method returns radian value of an angle.

Example

The following example shows the usage of radians() method.

#!/usr/bin/python3
import math

print ("radians(3) : ",  math.radians(3))
print ("radians(-3) : ",  math.radians(-3))
print ("radians(0) : ",  math.radians(0))
print ("radians(math.pi) : ",  math.radians(math.pi))
print ("radians(math.pi/2) : ",  math.radians(math.pi/2))
print ("radians(math.pi/4) : ",  math.radians(math.pi/4))

Output

When we run the above program, it produces the following result −

radians(3) :  0.0523598775598
radians(-3) :  -0.0523598775598
radians(0) :  0.0
radians(math.pi) :  0.0548311355616
radians(math.pi/2) :  0.0274155677808
radians(math.pi/4) :  0.0137077838904

python_numbers.htm



Description

Python number method radians() converts angle x from degrees to radians.

Syntax

Following is the syntax for radians() method −

radians(x)

Note − This function is not accessible directly, so we need to import math module and then we need to call this function using math static object.

Parameters

  • x − This must be a numeric value.

Return Value

This method returns radian value of an angle.

Example

The following example shows the usage of radians() method.

#!/usr/bin/python
import math

print "radians(3) : ",  math.radians(3)
print "radians(-3) : ",  math.radians(-3)
print "radians(0) : ",  math.radians(0)
print "radians(math.pi) : ",  math.radians(math.pi)
print "radians(math.pi/2) : ",  math.radians(math.pi/2)
print "radians(math.pi/4) : ",  math.radians(math.pi/4)

When we run above program, it produces following result −

radians(3) :  0.0523598775598
radians(-3) :  -0.0523598775598
radians(0) :  0.0
radians(math.pi) :  0.0548311355616
radians(math.pi/2) :  0.0274155677808
radians(math.pi/4) :  0.0137077838904

python_numbers.htm

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    degrees() and radians() are methods specified in math module in Python 3 and Python 2. 
    Often one is in need to handle mathematical computation of conversion of radians to degrees and vice-versa, especially in the field of geometry. Python offers inbuilt methods to handle this functionality. Both the functions are discussed in this article.

    radians()

    This function accepts the “degrees” as input and converts it into its radians equivalent. 
     

    Syntax : radians(deg) Parameters : deg : The degrees value that one needs to convert into radians Returns : This function returns the floating point radians equivalent of argument. Computational Equivalent : 1 Radians = 180/pi Degrees.

      Code #1 : Demonstrating radians() 

    Python3

    import math

    print("180 / pi Degrees is equal to Radians : ", end ="")

    print (math.radians(180 / math.pi))

    print("180 Degrees is equal to Radians : ", end ="")

    print (math.radians(180))

    print("1 Degrees is equal to Radians : ", end ="")

    print (math.radians(1))

    Output:

    180/pi Degrees is equal to Radians : 1.0
    180 Degrees is equal to Radians : 3.141592653589793
    1 Degrees is equal to Radians : 0.017453292519943295

    degrees()

    This function accepts the “radians” as input and converts it into its degrees equivalent. 
     

    Syntax : degrees(rad) Parameters : rad : The radians value that one needs to convert into degrees. Returns : This function returns the floating point degrees equivalent of argument. Computational Equivalent : 1 Degrees = pi/180 Radians.

      Code #2 : Demonstrating degrees() 

    Python3

    import math

    print("pi / 180 Radians is equal to Degrees : ", end ="")

    print (math.degrees(math.pi / 180))

    print("180 Radians is equal to Degrees : ", end ="")

    print (math.degrees(180))

    print("1 Radians is equal to Degrees : ", end ="")

    print (math.degrees(1))

    Output:

    pi/180 Radians is equal to Degrees : 1.0
    180 Radians is equal to Degrees : 10313.240312354817
    1 Radians is equal to Degrees : 57.29577951308232

    Application : There are many possible applications of these functions in mathematical computations related to geometry and has a certain applications in astronomical computations as well.


    How do you find the radian in Python?

    Description. The radians() method converts angle x from degrees to radians..
    Syntax. Following is the syntax for radians() method − radians(x) ... .
    Parameters. x − This must be a numeric value..
    Return Value. This method returns radian value of an angle..
    Example. The following example shows the usage of radians() method. ... .
    Output..

    What are radians in Python?

    Python radians() is an inbuilt method that is defined under the math module, which is used to convert the angle x( which is the parameter ) from degrees to radians. For example, if x is passed as a parameter in degrees, then the function (radians(x)) returns the radian value of that angle.

    How do you find radians and degrees in Python?

    Python Math: Convert radian to degree.
    Sample Solution:-.
    Python Code: pi=22/7 radian = float(input("Input radians: ")) degree = radian*(180/pi) print(degree) Sample Output: Input radians: 10 572.7272727272727..
    Pictorial Presentation:.
    Flowchart: ... .
    Python Code Editor: ... .
    Have another way to solve this solution?.

    Does Python work in radians?

    degrees() and radians() are methods specified in math module in Python 3 and Python 2. Often one is in need to handle mathematical computation of conversion of radians to degrees and vice-versa, especially in the field of geometry. Python offers inbuilt methods to handle this functionality.