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

yipeiwu_com6年前Python基础

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

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

degrees(x)

注意:此函数是无法直接访问的,所以我们需要导入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)

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

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


相关文章

Python 移动光标位置的方法

如下所示: x = file('1.txt','r') print x.tell() #显示当前光标位置 x.seek(3) print x.tell() #没有设置光标位置,...

Python数据可视化 pyecharts实现各种统计图表过程详解

Python数据可视化 pyecharts实现各种统计图表过程详解

1、pyecharts介绍 Echarts是一款由百度公司开发的开源数据可视化JS库,pyecharts是一款使用python调用echarts生成数据可视化的类库,可实现柱状图,折...

用Python代码来绘制彭罗斯点阵的教程

用Python代码来绘制彭罗斯点阵的教程

这里是显示彭罗斯点阵的Python的脚本。是的,这是可以运行的有效Phython代码。 译注:彭罗斯点阵,物理学术语。上世纪70年代英国数学家彭罗斯第一次提出了这个概念,称为彭罗斯点阵(...

python3安装speech语音模块的方法

python3安装speech语音模块的方法

在windows平台上使用pyhton编写语音识别程序需要用到speech模块,speech模块支持的主要功能有:文本合成语音,将键盘输入的文本信息转换为语音信号方式输出;语音识别,将输...

Django中使用group_by的方法

本文实例讲述了Django中使用group_by的方法。分享给大家供大家参考。具体分析如下: 在Django中怎样使用group_by语句呢?找了很多资料,都没有看到好的,在这里分享两种...