出租车计费问题➕等待时间

img

km = float(input('请输入公里数(km):'))
wait = float(input("请输入等待时间(s):"))
cost=0
if km <= 3 and km > 0:
    cost=10
if km >3 and km <= 10:
    cost = 10 + (km - 3) * 2
if km > 10:
    cost = 10 + (km - 3) * 2 + (km -10)*3
if wait >= 300:
    cost += int(wait / 300)*2
print('您需要支付%s'%cost,'元车费!')

img

参考:

img

s, t = eval(input().replace(' ', ','))
m = 10
if s <= 3:
    m += 0
elif s <= 10:
    m += (s - 3) * 2
else:
    m += 7 * 2
    m += (s - 10) * 3
if t > 5:
    m += (t - 5) * 2
print(round(m, 0), '元')

有帮助请采纳,有问题继续交流,你的采纳是对我回答的最大的肯定和动力