
上QQ阅读APP看书,第一时间看更新
5.2.1 数学函数
数学函数用于各种数学运算。数学函数的名称及返回值如表5.1所示。
表5.1 数学函数的名称及返回值

数学函数示例如下。
单击“开始”菜单,打开Python 3.6.5 Shell软件,然后在菜单栏中选择File→New File命令,创建一个Python文件,并命名为Python5-1.py,然后输入以下代码:

需要说明的是,首先要导入math模块,才可以使用该模块中的函数;否则程序会报错。
在菜单栏中选择Run→Run Module命令或按键盘上的F5键,就可以运行程序代码,结果如图5.1所示。

图5.1 数学函数示例的运行结果