Python math 模块提供了许多对浮点数的数学运算函数。
math 模块下的函数,return 值均为浮点数,除非另有明确说明。
如果尊敬的读者您需要计算复数,请使用 cmath 模块中的同名函数。
要使用 math 函数必须先导入:
import math
查看 math 模块中的内容:
>>> import math
>>> dir(math)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd'<