Python tan() 関数

Python 数字Python 数値


説明

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 数字Python 数値

その他の拡張