I asked a similar question regarding this same piece of code earlier but once again I have found myself stuck. Particularly on the generation of a license plate containing two letters, two numbers, and then two letters. I hope that this question isn't a duplicate but in this circumstance I am very stuck with what to do, this is the code so far and I hope you can identify where I am going wrong:
from datetime import date, datetime, time, timedelta
import time, string
from random import uniform, random
def timeDelta():
print("Average Speed Checker")
start = (input("Car has passed Cam1: "))
licensePlate = str(firstLetters + randomNumber + " " + secondLetters)
print(licensePlate)
if start in ("y"):
camInput1 = datetime.now()
print(camInput1)
print("Car is travelling...")
time.sleep(1)
print("Car is travelling...")
time.sleep(1)
print("Car has passed cam2")
camInput2 = camInput1 + timedelta(seconds = uniform(5, 10))
timeDelta = camInput2 - camInput1
distance = 200
duration = timeDelta.total_seconds()
print("Time Delta is equal to: {0}".format(duration))
speedCarMs = distance/duration
print("Car is travelling in m/s at: {0}".format(speedCarMs))
speedCarMph = 2.237*speedCarMs
print("Car is travelling in MPH at: {0}".format(speedCarMph))
if speedCarMph > 60:
fileInput:
def possibleNumber():
possibleNumbers = (1,2,3,4,5,6,7,8,9,0)
randomNumber = random.sample(possibleNumbers, 2)
def randomLetters1(y):
return ''.join(random.choice(string.ascii_uppercase) for x in range(y))
firstLetters = (randomLetters1(2))
secondLetters = (randomLetters1(3))
print("Choose which function you want to use: ")
while True:
answer = (input("Choice: "))
if answer in ("speed"):
timeDelta()
else:
print("Invalid response")
According to python, the issue is to do with this:
AttributeError: 'builtin_function_or_method' object has no attribute 'choice'