Python File handling: Seaching for specific numbers

2024/11/17 3:00:21

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.

Answer
if (speed>60)#Do what you want to 
https://en.xdnf.cn/q/119127.html

Related Q&A

How to convert token list into wordnet lemma list using nltk?

I have a list of tokens extracted out of a pdf source. I am able to pre process the text and tokenize it but I want to loop through the tokens and convert each token in the list to its lemma in the wor…

Script throws an error when it is made to run using multiprocessing

Ive written a script in python in combination with BeautifulSoup to extract the title of books which get populated upon providing some ISBN numbers in amazon search box. Im providing those ISBN numbers…

Efficiently pair random elements of list

I have a list of n elements say: foo = [a, b, c, d, e] I would like to randomly pair elements of this list to receive for example: bar = [[a, c], [b, e]] where the last element will be discarded if the…

ALL permutations of a list with repetition but not doubles

I have seen similar but not the same: here. I definitely want the permutations, not combinations, of all list elements. Mine is different because itertools permutation of a,b,c returns abc but not aba …

NameError: name current_portfolio is not defined

I am getting NameError: name current_portfolio is not defineddef initialize(context): context.sym = symbol(xxx) context.i = 0def handle_data(context, data):context.i += 1 if context.i < 60:returnsma…

Scrape an Ajax form with .submit() with Python and Selenium

I am trying to get the link from a web page. The web page sends the request using javascript, then the server sends a response which goes directly to download a PDF. This new PDF is automatically downl…

How to process break an array in Python?

I would like to use a double array. But I still fail to do it. This what I did. Folder = "D:\folder" Name = [gadfg5, 546sfdgh] Ver = [None, hhdt5463]for dn in Name :for dr in Ver :if dr is No…

Why am I getting replacement index 1 out of range for positional args tuple error

I keep getting this error: Replacement index 1 out of range for positional args tuple on this line of code: print("{1}, {2}, {3}, {4}".format(question[3]), question[4], question[5], question[…

Python: Find keywords in a text file from another text file

Take this invoice.txt for exampleInvoice NumberINV-3337Order Number12345Invoice DateJanuary 25, 2016Due DateJanuary 31, 2016And this is what dict.txt looks like:Invoice DateInvoice NumberDue DateOrder …

How to split a list into chucks of different sizes specified by another list? [duplicate]

This question already has answers here:How to Split or break a Python list into Unequal chunks, with specified chunk sizes(3 answers)Closed 4 years ago.I have an array I am trying to split into chunks …