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
声明:本站所有作品(图文、音视频)均由用户自行上传分享,或互联网相关知识整合,仅供网友学习交流,若您的权利被侵害,请联系 管理员 删除。
本文链接:http://news.ew35.com/
