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

yipeiwu_com5年前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计算windows全盘文件md5值的脚本

利用python计算windows全盘文件md5值的脚本

import hashlib import os import time import configparser import uuid def test_file_md5(fi...

Python3实现的腾讯微博自动发帖小工具

复制代码 代码如下:# -*- coding: UTF-8 -*-import mysql.connector as dbimport client.tWeiboimport time...

python+splinter实现12306网站刷票并自动购票流程

通过python+splinter,实现在12306网站刷票并自动购票流程(无法自动识别验证码)。 此类程序只是提高了12306网站的 <查询> 刷新频率(默认自动查询的刷新...

python 实时得到cpu和内存的使用情况方法

python 实时得到cpu和内存的使用情况方法

如下所示: #先下载psutil库:pip install psutil import psutil import os,datetime,time def getMemCpu()...

使用 Supervisor 监控 Python3 进程方式

使用 Supervisor 监控 Python3 进程方式

首先说明,Supervisor 只能安装在 Python 2.x 环境中! 但是基本上所有的 Linux 都同时预装了 Python 2.x 和 Python 3.x 版本,并且调用 p...