Python cos()返回x弧度的余弦。
cos(x)
x - 必须是数值。
此方法返回一个介于-1和1之间的数值,表示角度的余弦。
以下示例显示cos()方法的用法。
#!/usr/bin/python import 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)
当无涯教程运行上面的程序时,它产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/python/number-cos.html
来源:LearnFk无涯教程网
cos(3) : -0.9899924966 cos(-3) : -0.9899924966 cos(0) : 1.0 cos(math.pi) : -1.0 cos(2*math.pi) : 1.0
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)