Python math.cos() 方法
实例
求不同数字的余弦:
# Import math Libraryimport math# Return the cosine of different numbersprint (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 |