python 向上取整ceil 向下取整floor 四舍五入round log() 函数

都在math模块里面呀

import math
#以下返回值都是浮点型
math.log(x,base)#默认base=e自然对数
math.ceil(x)#向上取整
math.floor(x)#向下取整
math.round(x)#四舍五入

#math.log(x) 就相当于数学中的ln(x),x>0,求底数为e的对数,e = 2.718281828459;
#math.log10(x) 就相当于数学中的lg(x),x>0,求底数为10的对数;

发布了10 篇原创文章 · 获赞 5 · 访问量 922

猜你喜欢

转载自blog.csdn.net/qq_42774323/article/details/104942224