Python atan 函数计算指定表达式的三角反正切。反正切也称为正切的倒数。
在本节中,让我们通过示例讨论如何在 Python 编程语言中使用 atan 函数,其语法如下所示。
math.atan(number);
数字:它可以是您想找到反正切值的数字或有效的数值表达式。
- 如果 number 参数是正数或负数,则。atan 函数返回反正切值。
- 如果 number 参数不是数字,则返回 TypeError。
Python math atan 函数示例
atan 函数允许您查找数值的三角反正切。在此 atan 示例中,我们将查找不同数据类型的反正切值并显示输出。
首先,我们直接对正整数和负整数使用了 atan 函数。前两个 Python 语句查找相应值的反正切。
接下来,我们对 Tuple 和 List 项目使用了 atan 函数。如果您看到下图,它在它们上运行完美。接下来,我们直接在多个值上使用了 atan Math 函数。
在最后一个语句中,我们对字符串值使用了 math atan 函数,它返回 TypeError。请参阅 tan 函数文章以了解正切函数。
import math
Tup = (0.21, 0.12, 0.39, -0.89 , 0.42)
Lis = [-0.1, 0.92, 0.35, -0.46 , 0.85]
print('Arc Tangent value of Positive Number = %.2f' %math.atan(1))
print('Arc Tangent value of Negative Number = %.2f' %math.atan(-1))
print('Arc Tangent value of Tuple Item = %.2f' %math.atan(Tup[3]))
print('Arc Tangent value of List Item = %.2f' %math.atan(Lis[2]))
print('Arc Tangent value of Multiple Number = %.2f' %math.atan(0.10 + 0.20 - 0.40))
print('Arc Tangent value of String Value = ', math.atan('Hello'))
