好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Python学习第二十一课(math模块)

math数学模块是python3的标准库,下面讲一下math模块里的方法以及应用。

一、数学函数

math. ceil(x)取大于等于x的最小的整数值,如果x是一个整数,则返回x取大于等于x的最小的整数值,如果x是一个整数,则返回x

math. copysign ( x ,  y )把y的正负号加到x前面,可以使用0把y的正负号加到x前面,可以使用0把y的正负号加到x前面,可以使用0

math. fabs ( x )

math. factorial ( x )

math. floor ( x )

math. fmod ( x ,  y )

math. frexp ( x )

math. fsum ( iterable )

math. gcd ( a ,  b )

math. isclose ( a ,  b ,  * ,  rel_tol=1e-09 ,  abs_tol=0.0 )

math. isfinite ( x )

math. isinf ( x )

math. isnan ( x )

math. ldexp ( x ,  i )

math. modf ( x )

math. remainder ( x ,  y )

math. trunc ( x )

二、幂函数和对数函数 

math. exp ( x )

math. expm1 ( x )

math. log ( x [,  base ])

math. log1p ( x )

math. log2 ( x )

math. log10 ( x )

math. pow ( x ,  y )

math. sqrt ( x )

三、三角函数

math. acos ( x )

math. asin ( x )

math. atan ( x )

math. atan2 ( y ,  x )

math. cos ( x )

math. hypot ( x ,  y )

math. sin ( x )

math. tan ( x )

math. degrees ( x )

math. radians ( x )

math. acosh ( x )

math. asinh ( x )

math. atanh ( x )

math. cosh ( x )

math. sinh ( x )

math. tanh ( x )

四、特殊函数

math. erf ( x )

math. erfc ( x )

math. gamma ( x )

math. lgamma ( x )

五、常量

math. pi   π  = 3.141592…

math. e     e  = 2.718281…

math. tau      τ  = 6.283185…

math. inf  

math. nan  

查看更多关于Python学习第二十一课(math模块)的详细内容...

  阅读:29次