Python math.cos() 方法
示例
查詢不同數字的餘弦
# 匯入 math 庫
import math
# 返回不同數字的餘弦
print (math.cos(0.00))
print (math.cos(-1.23))
print (math.cos(10))
print (math.cos(3.14159265359))
自己動手試一試 »
定義和用法
math.cos()
方法返回一個數字的餘弦。
語法
math.cos(x)
引數值
引數 | 描述 |
---|---|
x | 必需。要查詢餘弦的數字。如果該值不是數字,則返回 TypeError。 |
技術詳情
返回值 | 一個 float 值,範圍從 -1 到 1,表示一個角度的餘弦。 |
---|---|
Python 版本 | 1.4 |