math——第三方标准库
math模块是提供完成特殊数学运算的函数,math 模块特别实现了许多对浮点数的数学运算函数. 下面就展示math模块的一些常用的方法
调用方法
import math
常用函数
函数 | 功能 | |
---|---|---|
math.e | f返回自然常数e | ![]() |
math.pi | 返回圆周率pi | ![]() |
math.log10(x) | 返回x的以10为底的对数 | ![]() |
math.exp(x) | 返回e的x次方 | ![]() |
math.log(x[, base]) | 返回x的以base为底的对数,base默认为e | ![]() |
math.pow(x, y) | 返回x的y次方 | ![]() |
math.sqrt(x) | 返回x的平方根 | ![]() |
math.ceil(x) | 返回不小于x的整数 | ![]() |
math.floor(x) | 返回不大于x的整数 | ![]() |
math.trunc(x) | 返回x的整数部分 | ![]() |
math.modf(x) | 返回x的小数和整数 | ![]() |
math.fabs(x) | 返回x的绝对值 | ![]() |
math.fmod(x, y) | 返回x%y(取余) | ![]() |
math.factorial(x) | 返回x的阶乘 | ![]() |
math.isinf(x) | 若x为无穷大,返回True;否则,返回False | ![]() |
math.isnan(x) | 若x不是数字,返回True;否则,返回False | ![]() |
math.sin(x) | 返回x(弧度)的三角正弦值 | |
math.asin(x) | 返回x的反三角正弦值 | |
math.cos(x) | 返回x(弧度)的三角余弦值 | |
math.acos(x) | 返回x的反三角余弦值 | |
math.tan(x) | 返回x(弧度)的三角正切值 |
上面只是math的常用函数的最基本的介绍,如果你想要了解更多或者不懂,你可以进入python官网或者使用help函数查看相关的用法,或者下面的网站去看看:
https://www.cnblogs.com/zhangboblogs/p/7860784.html
http://www.cnblogs.com/renpingsheng/p/7171950.html