Python math.cos() メソッド

Python math 模块Python math モジュール

Python math.cos(x)x ラジアンのコサイン値を返します。

Python バージョン: 1.4

構文

math.cos() メソッドの構文は次のとおりです:

math.cos(x)

パラメータの説明:

  • x-- 必須、数値。x が数値でない場合は TypeError を返します。

戻り値

x のコサイン値を表す浮動小数点数を返します。-1 から 1 の間です。

例

以下の例は数値のコサイン値を返します:

例

# math パッケージをインポート
import math

# コサイン値を出力
print (math.cos(0.00))
print (math.cos(-1.23))
print (math.cos(10))
print (math.cos(3.14159265359))

出力結果:

1.0
0.3342377271245026
-0.8390715290764524
-1.0

Python math 模块Python math モジュール

その他の拡張