关于一个python多组输入的小问题,关于地铁票费用一个向上取整的方法,代码不完善,求指教
题目如下:
里程 票价
(05] km 210] km 3
(5
(1015]km 428] km 6
(15-21] km 5
(21
28km以上每10km增加1元
输入多组
5.3
10
30.5
输出多组
3
3
7
# 多组输入
import math
m = 0
while True:
try:
x = eval(input())
if 0 < x <= 5:
m = m + 2
print(m)
elif 5 < x <= 10:
m = m + 3
print(m)
elif 10 < x <= 15:
m = m + 4
print(m)
elif 15 < x <= 21:
m = m + 5
print(m)
elif 21 < x <= 28:
m = m + 6
print(m)
elif x > 28:
if 0 < m <= 10:
pass
else:
m = math.ceil((m - 28) / 10) + 6
print(m)
except:
break