现在位置: 首页 > Python 3 教程 > 正文

Python math.atan() 方法

Python math 模块 Python math 模块

Python math.atan(x) 返回 x 的反正切值,以弧度为单位,结果范围在 -pi/2 到 pi/2 之间。

Python 版本: 1.6.1

语法

math.atan() 方法语法如下:

math.atan(x)

参数说明:

  • x -- 必需,个正数或负数。如果 x 不是一个数字,返回 TypeError。

返回值

返回一个浮点数,表示一个数字的反正切值,范围在 -pi/2 到 pi/2 之间。

实例

以下实例返回不同数字的反正切:

实例

# 导入 math 包
import math

# 输出反正切值
print (math.atan(0.39))
print (math.atan(67))
print (math.atan(-21))

输出结果:

0.37185607384858127
1.5558720618048116
-1.5232132235179132

Python math 模块 Python math 模块