溫馨提示×

python怎么導入cos函數

九三
350
2021-02-14 11:18:49
欄目: 編程語言

python怎么導入cos函數

在python中導入cos函數的方法

在python中使用cos函數時,cos()函數無法直接訪問,需要先導入math模塊,在通過靜態對象調用;

cos():cos函數的作用是返回x的弧度的余弦值。

cos()函數語法:

import math

math.cos(x)

cos()函數使用方法:

import math #導入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

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女