Python3 radians() Function

Python3 数字Python3 Numbers


Description

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

The relationship between degrees and radians is: 2π radians = 360°. Thus 1° ≈ 0.0174533 radians, and 1 radian ≈ 57.29578°.

  • 1) Formula to convert degrees to radians: radians = degrees ÷ 180 × π
  • 2) Formula to convert radians to degrees: degrees = radians × 180 ÷ π

Syntax

The syntax of the radians() method is as follows:

import math

math.radians(x)

Note:radians() cannot be accessed directly; you need to import the math module, and then call the method via the math static object.


Parameters

  • x -- An angle value, with the default unit being degrees.°。

Return Value

Returns the radian value of an angle.


Example

The following demonstrates an example of using the radians() method:

Example

#!/usr/bin/python3
import math

print ("radians(90) : ",  math.radians(90))     # 1 radian is approximately equal to 57.3°
print ("radians(45) : ",  math.radians(45))
print ("radians(30) : ",  math.radians(30))
print ("radians(180) : ",  math.radians(180))  # The radian of 180 degrees is π

print("180 / pi : ", end ="")
print (math.radians(180 / math.pi))

After running the above example, the output result is:

radians(90) :  1.5707963267948966
radians(45) :  0.7853981633974483
radians(30) :  0.5235987755982988
radians(180) :  3.141592653589793
180 / pi : 1.0

Python3 数字Python3 Numbers

Other Extensions