Python入门之三角函数tan()函数实例详解

我发现我好像变了,原来每当人成长的时候都会改变。生命本该有意义,我们绝不是白来一场。

描述

tan() 返回x弧度的正弦值。

语法

以下是 tan() 方法的语法:

import math
math.tan(x)

注意:tan()是不能直接访问的,需要导入 math 模块,然后通过 math 静态对象调用该方法。

参数

x -- 一个数值。

返回值

返回x弧度的正弦值,数值在 -1 到 1 之间。

实例

以下展示了使用 tan() 方法的实例:

#!/usr/bin/python
import math

print "tan(3) : ", math.tan(3)
print "tan(-3) : ", math.tan(-3)
print "tan(0) : ", math.tan(0)
print "tan(math.pi) : ", math.tan(math.pi)
print "tan(math.pi/2) : ", math.tan(math.pi/2)
print "tan(math.pi/4) : ", math.tan(math.pi/4)

以上实例运行后输出结果为:

tan(3) : -0.142546543074
tan(-3) : 0.142546543074
tan(0) : 0.0
tan(math.pi) : -1.22460635382e-16
tan(math.pi/2) : 1.63317787284e+16
tan(math.pi/4) : 1.0

总结

以上就是本文关于Python入门之三角函数tan()函数实例详解的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:Python入门之三角函数sin()函数实例详解、Python入门之三角函数atan2()函数详解、简单了解Python中的几种函数等,有什么问题可以随时留言,小编会及时回复大家的。感谢朋友们对本站的支持!

您可能有感兴趣的文章
Python自动化运维-使用Python脚本监控华为AR路由器关键路由变化

Python自动化运维-netmiko模块设备自动发现

Python自动化运维—netmiko模块连接并配置华为交换机

Python自动化运维-利用Python-netmiko模块备份设备配置

Python自动化运维-Paramiko模块和堡垒机实战