首页 > 编程知识 正文

python开根号保留整数,python对小数取整

时间:2023-05-03 07:51:16 阅读:189081 作者:2954

#开根
b=10
#例1
import math
a=math.sqrt(b)
print(a)
#例2
print(b**0.5)
结果:

#取整
c=1.564
#int
print(int( c ))
#floor
import math
print(math.floor( c ))
#round 四舍五入
print(round( c ))
结果:

#对数
import math
print(math.log(8,2)) #以2为底求8的对数
结果:

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。