python
取近似值
http://www.nowcoder.com/questionTerminal/3ab09737afb645cc82c35d56a5ce802a
python 中有个四舍六入五平分;所以不能直接使用,结合math中的进一法使用四舍五入;
import math
f = float(input())
x = f - int(f)
if x >= 0.5:
print(math.ceil(f))
else:
print(round(f))
取近似值
http://www.nowcoder.com/questionTerminal/3ab09737afb645cc82c35d56a5ce802a
import math
f = float(input())
x = f - int(f)
if x >= 0.5:
print(math.ceil(f))
else:
print(round(f))
相关推荐