python中三角函数

Python三角函数/方法 (Python Trigonometric 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 Trigonometric calculations, python has following Trigonometric functions, which are used to various purposes.

在python编程语言中 , 数学模块中定义了一些内置函数–它们可用于三角函数计算,python具有以下三角函数,可用于各种用途。

Python中的三角函数列表 (List of Trigonometric functions in Python)

Trigonometric functions

Description

Example

math.cos()

It returns the cosine of the number (in radians).

math.cos(x)

math.sin()

It returns the sine of the number (in radians).

math.sin(x)

math.tan()

It returns the tangent of the number in radians.

math.tan(x)

math.acos()

It returns the arc cosine of the number in radians.

math.acos(x)

math.asin()

It returns the arc sine of the number in radians.

math.asin(x)

math.atan()

It returns the arc tangent of the number in radians.

math.atan(x)

math.atan2()

It returns the result of the atan(y/x).

math.atan2(y,x)

math.pypot()

Return the Euclidean norm, sqrt(x*x + y*y).

math.pypot(x,y)

三角函数

描述

math.cos()

它返回数字的余弦(以弧度为单位)。

math.cos(x)

math.sin()

它返回数字的正弦(以弧度为单位)。

math.sin(x)

math.tan()

它以弧度形式返回数字的正切值。

math.tan(x)

math.acos()

它返回弧度数的反余弦值。

math.acos(x)

math.asin()

它返回弧度数的反正弦值。

math.asin(x)

math.atan()

它返回弧度数的反正切值。

math.atan(x)

math.atan2()

它返回atan(y / x)的结果 。

math.atan2(y,x)

math.pypot()

返回欧几里得范数sqrt(x * x + y * y) 。

math.pypot(x,y)

Python代码演示所有三角函数的示例 (Python code to demonstrate example of all Trigonometric functions)

# Python code to demonstrate example

# of all Trigonometric functions

# importing math module

import math

# number

x = 0.75

# math.cos()

print("math.cos(",x,"): ", math.cos(x));

# math.sin()

print("math.sin(",x,"): ", math.sin(x));

# math.tan()

print("math.tan(",x,"): ", math.tan(x));

# math.acos()

print("math.acos(",x,"): ", math.acos(x));

# math.asin()

print("math.asin(",x,"): ", math.asin(x));

# math.atan()

print("math.atan(",x,"): ", math.atan(x));

y = 2

# math.atan2(y,x) = atan(y/x)

print("math.atan2(",y,",",x,"): ", math.atan2(y,x))

# math.hypot(x,y)

print("math.hypot(",x,",",y,"): ", math.hypot(x,y))

Output

输出量

math.cos( 0.75 ): 0.7316888688738209

math.sin( 0.75 ): 0.6816387600233341

math.tan( 0.75 ): 0.9315964599440725

math.acos( 0.75 ): 0.7227342478134157

math.asin( 0.75 ): 0.848062078981481

math.atan( 0.75 ): 0.6435011087932844

math.atan2( 2 , 0.75 ): 1.2120256565243244

math.hypot( 0.75 , 2 ): 2.1360009363293826

三角函数的例外 (Exceptions with Trigonometric functions)

There are two types of exceptions occur,

有两种类型的异常发生,

ValueError

ValueError

When we provide an invalid value (number), this exception occurs.

当我们提供无效的值(数字)时,将发生此异常。

TypeError

TypeError

When we provide a different type of values except a number, this exception occurs.

当我们提供数字以外的其他类型的值时,会发生此异常。

ValueError example

ValueError示例

# python code to demonstrate example of

# math.asin() method with an exception

# importing math module

import math

# number

a = 2

print("asin(",a,") is = ", math.asin(a))

Output

输出量

Traceback (most recent call last):

File "/home/main.py", line 9, in print("asin(",a,") is = ", math.asin(a))

ValueError: math domain error

TypeError example

TypeError示例

# python code to demonstrate example of

# math.cos() method with an exception

# importing math module

import math

# number

a = "2"

print("cos(",a,") is = ", math.cos(a))

Output

输出量

Traceback (most recent call last):

File "/home/main.py", line 9, in print("acos(",a,") is = ", math.acos(a))

TypeError: a float is required

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

python中三角函数

python语言三角函数_python中三角函数_Python中的三角函数相关推荐

  1. 关于python浮点数类型错误的是_关于Python语言的浮点数类型,以下选项中描述错误的是...

    [单选题]关于Python字符串,以下选项中描述错误的是 [单选题]以下程序的输出结果是: lcat =["狮子","猎豹","虎猫",&q ...

  2. python要求所有浮点数必须带有小数部分对吗_关于 Python 语言的浮点数类型,以下选项中描述错误的是( )_学小易找答案...

    [简答题]请上传practice 2 完成图片 [填空题]作用在梁上的载荷一般可分为().().()三种. [填空题]梁根据约束有().().()三种基本类型. [单选题]关于 Python 的复数类 ...

  3. python语言单行注释以什么开头_python中单行注释以什么开头

    学会向程序中添加必要的注释,也是很重要的.注释不仅可以用来解释程序某些部分的作用和功能(用自然语言描述代码的功能),在必要时,还可以将代码临时移除,是调试程序的好帮手. 当然,添加注释的最大作用还是提 ...

  4. python语言format是什么意思_Python代码中str.format()函数有什么功能呢?

    摘要: 下文讲述Python代码中str.format()函数的简介说明,如下所示: str.format()函数功能 用于将字符串格式化,然后输出 str.format()函数语法 通过{} 和:替 ...

  5. python语言的数据类型有哪些_Python语言有哪些数据类型

    在Python中,能够直接处理的数据类型有以下几种: 一.整数 Python可以处理任意大小的整数,当然包括负整数,在Python程序中,整数的表示方法和数学上的写法一模一样,例如:1,100,-80 ...

  6. 以下可以采用python语言保留字的是-以下选项中,不是Python语言保留字的是_学小易找答案...

    [单选题]以下选项中,不是 Python 语言保留字的是 [连线题]将动机理论及其解释说明连线: [单选题]以下选项中,不是Python语言合法命名的是 [单选题]在Python函数中,用于获取用户输 ...

  7. 以下可以采用python语言保留字的是-以下选项中不是 Python 语言的保留字的是

    [单选题]病人李某,男,20岁,因患流脑入院,医生给磺胺嘧啶+TMP等药物治疗,嘱其服用磺胺嘧啶时首剂加倍,此目的是 [单选题]以下选项中不是 Python 语言的保留字的是 [单选题]关于毛果芸香碱 ...

  8. python语言的主要网站是_python语言主要是做什么的

    python是一款应用非常广泛的脚本程序语言,谷歌公司的网页就是用python编写.python在生物信息.统计.网页制作.计算等多个领域都体现出了强大的功能.python和其他脚本语言如java.R ...

  9. python语言句块的标记_Python语言语句块的标记是()

    [简答题] [单选题]Listen( 1.1-1) and answer: Karen Wood is ___________. [单选题]下列说法正确的是 ( ). [判断题]旅游的实质实人类追求自 ...

  10. python语言采用编译执行方式_Python程序的执行过程 解释型语言和编译型语言

    我初学Python时,听到的关于Python的第一句话就是,Python是一门解释性语言,我就这样一直相信下去,直到发现了*.pyc文件的存在.如果是解释型语言,那么生成的*.pyc文件是什么呢?c应 ...

最新文章

  1. StoneAge Dict 技术方案的可行性[1]
  2. access labsql 出错_一段由ACCESS转为SQL SERVER后出现的CINT错误
  3. websocket 学习--简单使用,nodejs搭建websocket服务器,到模拟股票,到实现聊天室
  4. @value 静态变量_springboot项目使用静态变量通过@Value注解获取配置文件内容
  5. GNU make manual 翻译(三十一)
  6. 校外访问不了cgbt.cn(403 forbidden)解决办法
  7. 【算法】普里姆算法 Prim算法解决修路问题
  8. shared_ptr使用场景、陷阱、性能分析,使用建议
  9. https原理:证书传递、验证和数据加密、解密过程解析
  10. 拷贝文件到另一台电脑
  11. python 获取当前路径_Python获取当前路径实现代码
  12. Centos7安装nxlog-2.9
  13. premiere cc2014破解版|premiere cc2014绿色破解版下载
  14. 使用VC++6.0创建.cpp文件工程
  15. 用PPT作数模论文图片的方法与技巧
  16. java检验电话或传真_对有java开发过程 常用的js验证数字、电话号码、传真、邮箱、手机号码、邮编、日期...
  17. 信号与系统——信号的分解
  18. C语言实现简易日历(附源码)
  19. Axure 制作验证码交互
  20. 具有多个项目的可访问拖放

热门文章

  1. android 使用adb命令安装安卓apk包
  2. 苹果7plus元件分布图_苹果iPhone7Plus元件分布图+电路原理图+位置图PDF
  3. delphi10 ftp文件名乱码问题
  4. mysql修改唯一索引
  5. Win10 + vs2017 编译并配置tesseract-5.0.0-alpha 遇到的问题
  6. js设计模式之命令模式
  7. 小程序后台PHP版本部署运行 LNMP+WNMP
  8. 好看的硬笔字体,怎样设计出好看的中国风艺术字体
  9. 萤石云 UIKit Javascript 使用
  10. comsol移动网格_COMSOL动网格调试