Home > Backend Development > Python Tutorial > 解读Python中degrees()方法的使用

解读Python中degrees()方法的使用

WBOY
Release: 2016-06-10 15:12:24
Original
2017 people have browsed it

 degrees()方法从弧度转换到度角x
语法

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

degrees(x)

Copy after login

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

返回值

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

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

下面的例子显示degrees()方法的使用。

#!/usr/bin/python
import math

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

Copy after login

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

degrees(3) : 171.887338539
degrees(-3) : -171.887338539
degrees(0) : 0.0
degrees(math.pi) : 180.0
degrees(math.pi/2) : 90.0
degrees(math.pi/4) : 45.0

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