math.atan_Python中带有示例的math.atan()方法
math.atan
Python math.atan()方法 (Python math.atan() method)
math.atan() method is a library method of math module, it is used to get the arc tangent, it accepts a number and returns the arc tangent value (in radians) of the given number.
math.atan()方法是数学模块的库方法,用于获取反正切,它接受一个数字并返回给定数字的反正切值(以弧度为单位)。
Note: math.atan() method accepts the only number, if we provide anything else except the number, it returns error TypeError - "TypeError: a float is required".
注意: math.atan()方法接受唯一的数字,如果我们提供除数字以外的其他任何内容,它将返回错误TypeError- “ TypeError:需要浮点数” 。
Syntax of math.atan() method:
math.atan()方法的语法:
math.atan(x)Parameter(s): x – is the number whose arc tangent to be calculated.
参数: x –是要计算其反正切值的数字。
Return value: float – it returns a float value that is the arc tangent value of the number x.
返回值: float-返回浮点值,该浮点值是数字x的反正切值。
Example:
例:
Input:a = 0.278# function callprint(math.atan(a))Output:0.27115314223853704Python代码演示math.atan()方法的示例 (Python code to demonstrate example of math.atan() method)
# python code to demonstrate example of # math.atan() method # importing math module import math# number a = -1 print("atan(",a,") is = ", math.atan(a))a = 0 print("atan(",a,") is = ", math.atan(a))a = 0.278 print("atan(",a,") is = ", math.atan(a))a = 1 print("atan(",a,") is = ", math.atan(a))a = 123 print("atan(",a,") is = ", math.atan(a))Output
输出量
atan( -1 ) is = -0.7853981633974483 atan( 0 ) is = 0.0 atan( 0.278 ) is = 0.27115314223853704 atan( 1 ) is = 0.7853981633974483 atan( 123 ) is = 1.5626664246149526TypeError example
TypeError示例
# python code to demonstrate example of # math.atan() method with an exception# importing math module import math# number a = "2" print("atan(",a,") is = ", math.atan(a))Output
输出量
Traceback (most recent call last):File "/home/main.py", line 9, in <module>print("atan(",a,") is = ", math.atan(a)) TypeError: a float is required翻译自: https://www.includehelp.com/python/math-atan-method-with-example.aspx
math.atan
总结
以上是生活随笔为你收集整理的math.atan_Python中带有示例的math.atan()方法的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 你以为用了BigDecimal后,计算结
- 下一篇: ntp symmetric_Python