我需要能夠循環條件的代碼,如果用戶想重複該程序,那麼它必須循環。如果用戶想要退出該程序,則應該顯示所有超速汽車的車牌。這是我迄今爲止:速度傳感器程序,循環,python 3,A級
import time
capturedtime=time.time()
speed_limit = 30
distance = 50
numberplates = []
newplate = ("Input number plate")
input("Press enter to start")
start_time = time.time()
input("Press enter to stop")
stop_time = time.time()
capturedtime = stop_time - start_time
print('Time taken: {:.2f} seconds'.format(capturedtime))
print('Distance: {:.2f}'.format(distance))
speed = distance/capturedtime
print('Speed: {:.2f}'.format(speed))
if speed > speed_limit:
print("You were breaking the speed limit")
numberplates.append(newplate)