-2
run = 1
list1 = []
for i in range(2):
while run > 0 :
print("-------------------------------------------------------")
run = 1
reg_num = input("Registration Number in caps: ")
tsh = int(input("Hour Entered : "))
tsm = int(input("Minute Entered : "))
tss = int(input("Second Entered : "))
print("")
teh = int(input("Hour Exited : "))
tem = int(input("Minute Exited : "))
tes = int(input("Second Exited : "))
print("Time Entered (camera1)", tsh, ":", tsm, ":", tss, "and Time Exited (camera2)", teh, ":", tem, ":", tes)
if tsh < teh:
tm = (((teh - tsh)*60) + (tem - tsm) +((tes - tss)/60))/60
elif tsh > teh:
teh = 24 + teh
tm = (((teh - tsh)*60) + (tem - tsm) +((tes - tss)/60))/60
speed = run/tm
print("speed of", reg_num, "is", "{:.2f}".format(speed), "mph")
if speed > 70:
list1.append(reg_num)
break
print("Overspeeding vehicles are: ")
for item in list1:
print (item)
这是计算通过相隔1英里的速度摄像头的车辆速度的代码。我必须列出超过限速的车辆列表。问题是代码计算速度(速度=运行/时间)错误消息说明“tm”(总分钟)没有被定义。你能修改一下,告诉我什么是错的。为什么'tm'不能作为if语句的变量注册?
小心解释你正在做什么,什么是不工作? –
此代码发生了什么?你提到一条计算线,但为什么?你是否得到某种例外?如果是这样,请包括完整的追溯。 – Blckknght
你的'if'和'elif'条件是一样的。 –