import math #导包
方法
math.e
math.pi
math.exp(x)
math.log(x[, base])
math.log10(x)
math.pow(x, y)
math.sqrt(x)
math.ceil(x)
math.floor(x)
math.modf(x)
math.fmod(x, y)
math.factorial(x)
math.sin(x), math.cos(x), math.tan(x)
math.asin(x),math.acos(x), math.atan(x)
测试
print(math.e) 2.718281828459045
print(math.pi) 3.141592653589793
print(math.exp(2)) 7.38905609893065
print(math.log(math.e)) 1.0
print(math.log10(10)) 1.0
print(math.pow(2,3)) 8.0
print(2**3) 8
print(math.pow(2,3)==2**3) True
print(math.sqrt(4)) 2.0
print(math.ceil(2.3)) 3
print(math.floor(2.3)) 2
print(math.modf(2.3)) (0.2999999999999998, 2.0)
print(math.fmod(-1,2)) -1.0
print(math.fmod(1,-2)) 1.0
注意区别:
print(-1%2) 1
print(1%-2) -1
print(math.factorial(5)) 120
print(math.sin(math.pi)) 1.2246467991473532e-16