Home > Backend Development > Python Tutorial > Python中转换角度为弧度的radians()方法

Python中转换角度为弧度的radians()方法

WBOY
Release: 2016-06-10 15:12:23
Original
2238 people have browsed it

 radians()方法把角度转化为弧度角x。
语法

以下是radians()方法的语法:

radians(x)

Copy after login

注意:此函数是无法直接访问的,所以我们需要导入math模块,然后需要用math的静态对象来调用这个函数。
参数

  • x -- 这必须是一个数值。

返回值

此方法返回一个角度的弧度值。
例子

下面的示例演示radians()方法的使用。

#!/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)

Copy after login

当我们运行上面的程序,它会产生以下结果:

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

Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template