4 python数学函数

 1 import math
 2 
 3 #向上取整
 4 print "math.ceil---"
 5 print "math.ceil(2.3) => ", math.ceil(2.3)
 6 print "math.ceil(2.6) => ", math.ceil(2.6)
 7 
 8 #向下取整
 9 print "\nmath.floor---"
10 print "math.floor(2.3) => ", math.floor(2.3)
11 print "math.floor(2.6) => ", math.floor(2.6)
12 
13 #四舍五入
14 print "\nround---"
15 print "round(2.3) => ", round(2.3)
16 print "round(2.6) => ", round(2.6)
17 
18 #这三个的返回结果都是浮点型
19 print "\n\nNOTE:every result is type of float"
20 print "math.ceil(2) => ", math.ceil(2)
21 print "math.floor(2) => ", math.floor(2)
22 print "round(2) => ", round(2)
23 
24 
25 ###绝对值函数
26 abs()

猜你喜欢

转载自www.cnblogs.com/2mei/p/9254030.html