The Longest Code That Ive Created
The Longest Code That Ive Created
locationlist = []
print("C:Record Data")
print("E:Quit")
print()
if (choice != "A") and (choice != "B") and (choice != "C") and (choice != "D") and (choice != "E"):
response = str(input("Do you wish to continue? Press Enter to continue and Q to Quit: "))
if (response == "Q"):
break
else:
truth == "True"
elif(choice == "A"):
res = str(input("Would you like to enter new camera location? Type 'Yes' for editing and 'No'
for viewing the list: "))
constant = "CameraLocationList.txt"
locfile = open(constant,"a")
locfile.write(location+"\n")
locationlist.append(location)
res = str(input("Would you like to another new camera location? Type 'Yes' for editing
and 'No' for viewing the list: "))
locfile.close()
print()
if(locationlist == []):
print("---------------------------------------------")
print()
print()
print("-------------------------------------------------------------------------------")
print()
else:
print("---------------------------------------------")
locEndfile = open(constant,"r")
x = locEndfile.readlines()
xcounter = 1
for line in x:
print(xcounter," ",line)
xcounter += 1
locEndfile.close()
print("-------------------------------------------------------------------------------")
elif(choice == "B"):
print()
print("Please choose the driver's speed:")
print("Speed(km/h)"+"\t"+"Fine"+"\t\t"+"Merit"+"\t\t"+"Status")
print("-------------------------------------------------------------------------------")
print("111-140"+"\t\t"+"150"+"\t\t"+"1 "+"\t\t"+"Speeding")
print("141-159"+"\t\t"+"200"+"\t\t"+"2 "+"\t\t"+"Speeding")
print(">=160 "+"\t\t"+"250"+"\t\t"+"Jail"+"\t\t"+"Speeding")
print()
fine = "150"
merit = "1"
fine = "200"
merit = "2"
fine = "250"
merit = "Jail"
else:
print("Error!")
print()
print()
locEndfile = open(constant,"r")
x = locEndfile.readlines()
xcounter = 1
for line in x:
print(xcounter," ",line)
xcounter += 1
locEndfile.close()
if (loc == "1"):
locationspeeding = locationlist[0]
locationspeeding = locationlist[1]
locationspeeding = locationlist[2]
locationspeeding = locationlist[3]
locationspeeding = locationlist[4]
locationspeeding = locationlist[5]
locationspeeding = locationlist[6]
locationspeeding = locationlist[7]
locationspeeding = locationlist[8]
locationspeeding = locationlist[9]
elif (loc == "11"):
locationspeeding = locationlist[10]
else:
elif(choice == "C"):
speedingR = open("SpeedingRecord.txt","a")
offender = (str(name)+"\t"+str(iD)+"\t"+str(phonenum)+"\t"+str(speed)+"\t"+str(fine)+"\
t"+str(merit)+"\t"+str(locationspeeding))
speedingR.write(offender+"\n")
speedingR.close()
print()
elif(choice == "D"):
print()
print("Name\tID\t\tPhone No.\tSpeed\tFine\tMerit\tLocation")
speedingRread = open("SpeedingRecord.txt","r")
print("\n")
z = speedingRread.readlines()
for line in z:
print(line+"\n")
speedingRread.close()
elif(choice == "E"):
truth = "False"
else:
print("Invalid syntax!")
truth = "False"
FUNCTION ADDED:
def viewcameraLoction(constant):
locEndfile = open(constant,"r")
x = locEndfile.readlines()
xcounter = 1
for line in x:
print(xcounter," ",line)
xcounter += 1
locEndfile.close()
def speedEvaluation(speed):
fine = "150"
merit = "1"
fine = "200"
merit = "2"
fine = "250"
merit = "Jail"
else:
print("Error!")
return fine,merit
def saveDataC(name,iD,phonenum,speed,fine,merit,locationspeeding):
speedingR = open("SpeedingRecord.txt","a")
offender = (str(name)+"\t"+str(iD)+"\t"+str(phonenum)+"\t"+str(speed)+"\t"+str(fine)+"\
t"+str(merit)+"\t"+str(locationspeeding))
speedingR.write(offender+"\n")
speedingR.close()
def displayD():
print()
print("Name\tID\t\tPhone No.\tSpeed\tFine\tMerit\tLocation")
speedingRread = open("SpeedingRecord.txt","r")
print("\n")
z = speedingRread.readlines()
for line in z:
print(line+"\n")
speedingRread.close()
def exit():
def main():
truth = "True"
locationlist = []
print("C:Record Data")
print("E:Quit")
print()
response = str(input("Do you wish to continue? Press Enter to continue and Q to Quit: "))
print()
if (response == "Q"):
exit()
break
else:
truth == "True"
elif(choice == "A"):
res = str(input("Would you like to enter new camera location? Type 'Yes' for editing and
'No' for viewing the list: "))
constant = "CameraLocationList.txt"
locfile = open(constant,"a")
locfile.write(location+"\n")
locationlist.append(location)
res = str(input("Would you like to another new camera location? Type 'Yes' for editing
and 'No' for viewing the list: "))
locfile.close()
print()
if(locationlist == []):
print("---------------------------------------------")
print()
print()
print("-------------------------------------------------------------------------------")
print()
else:
print("---------------------------------------------")
viewcameraLoction(constant)
print("-------------------------------------------------------------------------------")
elif(choice == "B"):
print()
print("Speed(km/h)"+"\t"+"Fine"+"\t\t"+"Merit"+"\t\t"+"Status")
print("-------------------------------------------------------------------------------")
print("111-140"+"\t\t"+"150"+"\t\t"+"1 "+"\t\t"+"Speeding")
print("141-159"+"\t\t"+"200"+"\t\t"+"2 "+"\t\t"+"Speeding")
print(">=160 "+"\t\t"+"250"+"\t\t"+"Jail"+"\t\t"+"Speeding")
print()
f,m = speedEvaluation(speed)
print()
print()
viewcameraLoction(constant)
if (loc == "1"):
locationspeeding = locationlist[0]
locationspeeding = locationlist[1]
locationspeeding = locationlist[2]
locationspeeding = locationlist[3]
locationspeeding = locationlist[4]
locationspeeding = locationlist[5]
locationspeeding = locationlist[6]
locationspeeding = locationlist[7]
locationspeeding = locationlist[8]
locationspeeding = locationlist[9]
locationspeeding = locationlist[10]
else:
elif(choice == "C"):
saveDataC(name,iD,phonenum,speed,f,m,locationspeeding)
print()
elif(choice == "D"):
displayD()
elif(choice == "E"):
exit()
break
else:
print("Invalid syntax!")
truth = "False"
main()