Python Angular转换函数/方法 (Python Angular conversion functions/methods)

In python programming language, there are some of the built-in functions which are defined in math module – they can be used for angular conversion i.e. to convert angle values, there are two angular conversion functions:

在python编程语言中 , 数学模块中定义了一些内置函数–它们可用于角度转换,转换角度值 ,有两个角度转换函数

  1. math.degrees()

    math.degrees()

    It is used to convert angle value from radians to degrees.

    用于将角度值从弧度转换为度。

  2. math.radians()

    math.radians()

    It is used to convert angle value from degrees to radians.

    用于将角度值从度转换为弧度。

Syntax of math.degrees() and math.radians() functions:

math.degrees()和math.radians()函数的语法:

    math.degrees(x)
math.radians(x)

Example:

例:

    Input:
x = 10.25 # value in radians
# converting & printing in degrees
x = math.degrees(x)
print(x)
# again, converting & printing in radians
x = math.radians(x)
print(x)
Output:
587.2817400090938
10.25

Python代码演示角度转换函数的示例 (Python code to demonstrate example of angular conversion functions)

# Python code to demonstrate example of
# math.degrees() and math.radians() methods
# importing math module
import math
# angle x in radians
x = 10.25
print("x in radians: ", x)
# converting to degrees
x = math.degrees(x)
print("x in degrees: ", x)
# now again converting to radians
x = math.radians(x)
print("x in radians: ", x)

Output

输出量

x in radians:  10.25
x in degrees:  587.2817400090938
x in radians:  10.25

Note: If we provide anything except a number type value to these functions, they returns a TypeError.

注意:如果我们向这些函数提供数字类型值以外的任何东西,它们将返回TypeError

# Python code to demonstrate example of
# math.degrees() with exception
# importing math module
import math
# angle x in string (invalid)
x = "10.25"
# converting to degrees
x = math.degrees(x)
print("x in degrees: ", x)

Output

输出量

Traceback (most recent call last):
File "/home/main.py", line 12, in <module>
x = math.degrees(x)
TypeError: a float is required

翻译自: https://www.includehelp.com/python/angular-conversion-functions.aspx

Python中的角度转换功能相关推荐

  1. python中绝对角度是什么意思_Python中的角度转换功能

    Python Angular转换函数/方法 在python编程语言中,数学模块中定义了一些内置函数–它们可用于角度转换,即转换角度值,有两个角度转换函数:math.degrees() 用于将角度值从弧 ...

  2. python进制转换函数-Python中进制转换函数的使用

    Python中进制转换函数的使用 关于Python中几个进制转换的函数使用方法,做一个简单的使用方法的介绍,我们常用的进制转换函数常用的就是int()(其他进制转换到十进制).bin()(十进制转换到 ...

  3. python中进制转换关系

    python中进制转换关系 标题整数之间的进制转换: hex(16) # 10进制转16进制 print(hex(16) ) >>'0x10' oct(8) # 10进制转8进制 prin ...

  4. 站长在线Python精讲:Python中字符串编码转换encode编码和decode解码详解

    欢迎你来到站长在线的站长学堂学习Python知识,本文学习的是<Python中字符串编码转换:encode编码和decode解码详解>.本知识点主要内容有:常用编码简介.使用encode( ...

  5. Python中二进制十进制转换

    hello大家好,今天我想和大家分享一下在Python中进制转换加减法的方法. 比如现在我们需要求100 + 10,然后需要将结果110以二进制的形式返回,又或者我们现在有一个小需求,就是要计算二进制 ...

  6. python如何小写p转换p_Python进阶---python 中字符串大小写转换

    python中字符串的大小写转换和判断字符串大小写的函数小结: 一.pyhton字符串的大小写转换, 常用的有以下几种方法: 1.对字符串中所有字符(仅对字母有效)的大小写转换,有两个方法: prin ...

  7. python如何查看有什么模块_在python中如何查看模块功能

    在python中查看模块功能的方法:1.在python命令行输入help()函数进入help帮助文档界面:2.键入[modules]列出当前所有安装的模块:3.键入相应的模块名称即可得到该模块的功能信 ...

  8. python中字符串大小写转换常用操作

    python中字符串的大小写转换操作 方法名 操作说明 upper() 把字符串中的字符全部转换为大写 lower() 把字符串中的字符全部转换为小写 swapcase() 把原字符串中的字符,大写变 ...

  9. python 中字符串大小写转换

    python中字符串的大小写转换和判断字符串大小写的函数小结: 一.pyhton字符串的大小写转换, 常用的有以下几种方法: 1.对字符串中所有字符(仅对字母有效)的大小写转换,有两个方法: prin ...

  10. Python中的mkdir -p功能[重复]

    本文翻译自:mkdir -p functionality in Python [duplicate] This question already has an answer here: 这个问题在这里 ...

最新文章

  1. 《信息系统项目管理师软考辅导——3年真题详解与全真模拟》主要创新点、关注点...
  2. Spring Sleuth和Zipkin跟踪微服务
  3. 数据结构与算法笔记(十一)—— 归并排序
  4. myeclipse-pro-2013-SR2 下载地址
  5. 你对5G技术“低延时”可能有些误解——专访虎牙5G 首席架构师林正显
  6. caffe/common.cu error: function atomicadd has already been defined
  7. 22个学习Python必备的库,你是否还有没见过的呢
  8. 181025词霸有道扇贝每日一句
  9. 使用WireShark协议分析仪来分析ICMP与FTP协议
  10. 成本会计的概念、产品成本核算的要求、产品成本核算的对象与成本项目、产品成本的归集和分配(可能考判断)、产品成本计算方法 (三种:产品的品种(品种法),批次(分批法),步骤(分步法))
  11. 十二星座物语,女生最喜欢的星座性格【1】
  12. 【函数参数传递】编写一个函数,统计字符串中小写字母的个数,并把字符串中的小写字母转化成大写字母。
  13. JS调用拨打电话功能
  14. JVM的mixed mode
  15. ibm service guide
  16. OCP考试如何确定考试中心
  17. 天宇,snapseed,第六课,静物人像
  18. 免费下载各种json包的网址
  19. DvaJS快速上手(3)
  20. 糟糕!服务器被植入挖矿木马,CPU飙升200%

热门文章

  1. arangoDB基本操作
  2. core音标_core的意思在线翻译,解释core中文英文含义,短语词组,音标读音,例句,词源【澳典网ODict.Net】...
  3. xdb 服务_localhost 8080 XDB服务器需要用户名和密码的问题
  4. postgresql 数据库 update更新慢的原因(已解决)
  5. 什么是 503 服务不可用错误?
  6. [RK3288][Android5.1] 调试笔记 --- LVDS+EDP双屏机器调节白平衡色温
  7. 2018DeeCamp笔试题目第2套A卷
  8. Part 66 - Check及Uncheck所有CheckBox 同时删除多行数据记录的实现
  9. cpu多开测试软件,游戏多开CPU优化工具
  10. 计算机显卡怎样安装方法,电脑显卡怎么安装?轻松安装电脑显卡的方法