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后,计算结
- 下一篇: MySQL 索引失效的 15 种场景!