码迷,mamicode.com
首页 > 编程语言 > 详细

Python tan() 函数

时间:2017-10-17 16:30:10      阅读:352      评论:0      收藏:0      [点我收藏+]

标签:nbsp   静态   静态对象   语法   实例   div   函数   log   弧度   

描述

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


语法

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

import math

math.tan(x)

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


参数

  • x -- 一个数值。

返回值

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


实例

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

#!/usr/bin/python3
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.1425465430742778
tan(-3) :  0.1425465430742778
tan(0) :  0.0
tan(math.pi) :  -1.2246467991473532e-16
tan(math.pi/2) :  1.633123935319537e+16
tan(math.pi/4) :  0.9999999999999999

Python tan() 函数

标签:nbsp   静态   静态对象   语法   实例   div   函数   log   弧度   

原文地址:http://www.cnblogs.com/wushuaishuai/p/7682241.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!