|||
>>> 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
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-5 04:50
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社