Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm creating a document in which I need to record license plates of vehicles (it's a practice exercise, nothing illegal) and calculate the speed they travel at and display all the vehicles that are travelling over 60 miles per hour. I'm pretty new to file handling and have no idea how to get Python to search for specific numbers. Help!

Code so far:

plate = "blank"
sensor1 = "blank"
sensor2 = "blank"
timetaken = "blank"
speed = "blank"

plate = input("Please input the license plate of the vehicle.")

sensor1 = float(input("Input the time the vehicle passed sensor 1."))
sensor2 = float(input("Input the time the vehicle passed sensor 2."))

timetaken = (sensor2 - sensor1)

print("The time taken for the vehicle to travel between the two sensors in  seconds:")
print(timetaken)

speed = (5/timetaken)
print("Vehicle speed in miles per hour:")
print(speed)

Edit: I appreciate the help but I'm not sure how I can search the .txt document that will be created later on to search for a specific license plate.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
212 views
Welcome To Ask or Share your Answers For Others

1 Answer

if (speed>60)
    #Do what you want to 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...