python3 向上取整ceil

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import math


print("math.ceil---向上取整")
print("math.ceil(2.3) => ", math.ceil(2.3)) # 3
print("math.ceil(2.6) => ", math.ceil(2.6)) # 3

#向下取整
print("nmath.floor---向下取整")
print("math.floor(2.3) => ", math.floor(2.3)) # 2
print("math.floor(2.6) => ", math.floor(2.6)) # 2

#四舍五入
print("nround---四舍五入")
print("round(2.3) => ", round(2.3)) # 2
print("round(2.6) => ", round(2.6)) # 3
1
2
3
4
5
6
7
8
9
10
11
math.ceil---向上取整
math.ceil(2.3) => 3
math.ceil(2.6) => 3

math.floor---向下取整
math.floor(2.3) => 2
math.floor(2.6) => 2

round---四舍五入
round(2.3) => 2
round(2.6) => 3