开发手册 欢迎您!
软件开发者资料库

Python math.cos() 方法

Python math模块中定义了一些数学函数。由于这个模块属于编译系统自带,因此它可以被无条件调用。该模块还提供了与用标准C定义的数学函数的接口。本文主要介绍Python math.cos() 方法的使用,以及相关示例代码。

Python math.cos() 方法

Python Math方法

例如:

查找不同数字的余弦值:

# Import math Libraryimport math# 返回不同数字的余弦值print (math.cos(0.00))print (math.cos(-1.23))print (math.cos(10))print (math.cos(3.14159265359))

1、定义和用法

math.cos()方法返回数字的余弦值。

2、调用语法

math.cos(x)

3、参数说明

参数

描述

x

必需的参数, 查找余弦的数字。 如果该值不是数字,

则返回TypeError

4、方法说明

返回值:

float值,从-1到1,表示角度的余弦

Python Version:

1.4

Python Math方法