>>> import math
# math.floor(x) returns the floor of x as a float, the largest integer value less than or equal to x.
>>> math.floor(9.2)
9.0
# math.sqrt(x) returns the square root of x.
>>> math.sqrt(81)
9.0
# math.pow(x,y) returns x raised to the power y.
>>> math.pow(2,3)
8.0
# math.log10(x) returns the base-10 logarithm of x.
>>> math.log10(100)
2.0
# math.exp(x) returns e**x.
>>> math.exp(2)
7.38905609893065
# check if the float x is a NaN
>>> math.isnan(x)
#equivalent to the output of float('nan').
>>> math.nan # python3
nan
>>> math.pi
3.141592653589793
>>> math.e
2.718281828459045
转载本文请联系原作者获取授权,同时请注明本文来自刘洋洋科学网博客。
链接地址:http://blog.sciencenet.cn/blog-3031432-1015385.html
上一篇:Python: operators
下一篇:Python 2: strings