描述
tan() 返回x弧度的正弦值。
語法
以下是 tan() 方法的語法:
1
2
|
import math math.tan(x) |
注意:tan()是不能直接訪問的,需要導入 math 模塊,然后通過 math 靜態對象調用該方法。
參數
x -- 一個數值。
返回值
返回x弧度的正弦值,數值在 -1 到 1 之間。
實例
以下展示了使用 tan() 方法的實例:
1
2
3
4
5
6
7
8
9
|
#!/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 ) |
以上實例運行后輸出結果為:
1
2
3
4
5
6
|
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()函數實例詳解的全部內容,希望對大家有所幫助。有什么問題可以隨時留言,小編會及時回復大家的。感謝朋友們對本站的支持!
原文鏈接:http://www.runoob.com/python/func-number-tan.html