python 向上取整和向下取整
math 模块
math.ceil() 向上取整
math.floor() 向下取整
# 导入 math 包
import math
# 输出向下舍入到最接近的整数
print(math.floor(0.6))
print(math.floor(1.4))
print(math.floor(5.3))
print(math.floor(-5.3))
print(math.floor(22.6))
print(math.floor(10.0))
math 模块
math.ceil() 向上取整
math.floor() 向下取整
# 导入 math 包
import math
# 输出向下舍入到最接近的整数
print(math.floor(0.6))
print(math.floor(1.4))
print(math.floor(5.3))
print(math.floor(-5.3))
print(math.floor(22.6))
print(math.floor(10.0))