python什么时候要调用math库,直接运算不行吗,我有点记不清楚了,是不是好像跟浮点数有关
math库里面包含了许多科学计算的库,比如sin cos函数等等,直接计算不来的
NAME: math
描述: This module provides access to the mathematical functions defined by the C standard.
这个模块提供对数学函数的访问,由C标准定义。
使用下面这些要调用math库:
FUNCTIONS
acos(x, /)
acosh(x, /)
asin(x, /)
asinh(x, /)
atan(x, /)
atan2(y, x, /)
atanh(x, /)
ceil(x, /)
comb(n, k, /)
copysign(x, y, /)
cos(x, /)
cosh(x, /)
degrees(x, /)
dist(p, q, /)
erf(x, /)
erfc(x, /)
exp(x, /)
expm1(x, /)
fabs(x, /)
factorial(x, /)
floor(x, /)
fmod(x, y, /)
frexp(x, /)
fsum(seq, /)
gamma(x, /)
gcd(*integers)
hypot(...)
isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)
isfinite(x, /)
isinf(x, /)
isnan(x, /)
isqrt(n, /)
lcm(*integers)
ldexp(x, i, /)
lgamma(x, /)
log(...)
log10(x, /)
log1p(x, /)
log2(x, /)
modf(x, /)
nextafter(x, y, /)
perm(n, k=None, /)
pow(x, y, /)
prod(iterable, /, *, start=1)
radians(x, /)
remainder(x, y, /)
sin(x, /)
sinh(x, /)
sqrt(x, /)
tan(x, /)
tanh(x, /)
trunc(x, /)
ulp(x, /)
什么时候要调用math库,直接运算不行吗
直接你会写运算代码,也可以写啊,只是可能你写的很复杂,没有别人的运行快,而已有现成的,为什么不用