math.floor()
和 math.ceil()
函数:math.floor()
返回一个数的向下取整值,math.ceil()
返回向上取整值。例如:
import math x = 4.7 print("The floor value of", x, "is", math.floor(x)) print("The ceiling value of", x, "is", math.ceil(x))
输出:
The floor value of 4.7 is 4 The ceiling value of 4.7 is 5