靚麗時尚館

位置:首頁 > 健康生活 > 心理

python中cost用法

心理1.13W
python中cost用法

Python cos() 函數

描述

cos() 返回x的弧度的餘弦值

語法

以下是 cos() 方法的語法:

import math

(x)

注意:cos()是不能直接訪問的,需要導入 math 模塊,然後通過 math 靜態對象調用該方法。

參數

x -- 一個數值

返回值

返回x的弧度的餘弦值,-1 到 1 之間。

以下展示了使用 cos() 方法的實例:

#!/usr/bin/python

import math

print "cos(3) : ", (3)

print "cos(-3) : ", (-3)

print "cos(0) : ", (0)

print "cos() : ", ()

print "cos(2*) : ", (2*)

以上實例運行後輸出結果爲:

cos(3) : -0.9899924966

cos(-3) : -0.9899924966

cos(0) : 1.0

cos() : -1.0

cos(2*) : 1.0

標籤:python cost