我正在尝试编写一个Python程序,收取停放多少小时的停车费。直到分钟超过300计算停车费。 '&'versus'and'
我已经打了回报,每次我这样做,输入后,我会得到圆满完成无输出时间
,一切工作正常。
当我投入600分钟(10小时)的时候,应该是30美元,我得到40美元的费用。
这里是我的代码:
import math
rate1 = 5
rate2 = 4
rate3 = 3
m = int(input('Please enter the number of minutes parked: '))
if m <= 60:
x = m/60
fee = math.ceil(x) * 5
print('Parking fee for',m,'minutes is $',fee)
elif m>60 & m<=300:
x = m/60
fee = math.ceil(x) * rate2
print('Parking fee for',m,'minutes is $',fee)
elif m>300:
x = m/60
fee = math.ceil(x) * rate3
print('Parking fee for',m,'minutes is $',fee)
else:
print('Invalid input')
输出:
Please enter the number of minutes parked: 600
Parking fee for 600 minutes is $ 40
Process finished with exit code 0
您需要缩进'if'语句的正文。 – Barmar
有一个编辑挂起正确缩进'if'语句的正文。请注意待处理的编辑。 – ndim