python中tan函数如何表示_Python入门之三角函数tan()函数实例详解

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-22 16:46   79   0

python 的 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()函数实例详解的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:、、等,有什么问题可以随时留言,小编会及时回复大家的。感谢朋友们对本站的支持!

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP