PythonのCOS()関数
説明
COS()は、xラジアンの余弦を返します。
文法
次の構文COS()メソッドです。
import math math.cos(x)
注:CoSは()に直接アクセスすることはできません、あなたは数学のモジュールをインポートしてから、数学静的オブジェクトによってメソッドを呼び出す必要があります。
パラメータ
- X - 値。
戻り値
-1の間の1へのxラジアンの余弦を返します。
例
以下は、メソッド)、COS(の使用例を示しています
#!/usr/bin/python import math print "cos(3) : ", math.cos(3) print "cos(-3) : ", math.cos(-3) print "cos(0) : ", math.cos(0) print "cos(math.pi) : ", math.cos(math.pi) print "cos(2*math.pi) : ", math.cos(2*math.pi)
上の例の出力を実行した後です。
cos(3) : -0.9899924966 cos(-3) : -0.9899924966 cos(0) : 1.0 cos(math.pi) : -1.0 cos(2*math.pi) : 1.0