truth = "True"
locationlist = []
while (truth == "True"):
print("--------Traffic OPS Summon----------------")
print("A:View and Edit the camera Location")
print("B:Enter New Speeding offence")
print("C:Record Data")
print("D:Display Speeding Summon File")
print("E:Quit")
print()
choice = str(input("Choice: "))
if (choice != "A") and (choice != "B") and (choice != "C") and (choice != "D") and (choice != "E"):
print("Invalid option was entered. Try again.")
response = str(input("Do you wish to continue? Press Enter to continue and Q to Quit: "))
if (response == "Q"):
print("Thank You for Using The System!")
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: "))
while (res == "Yes"):
constant = "CameraLocationList.txt"
locfile = open(constant,"a")
location = input("Enter camera location: ")
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("List of Speed Camera Location")
print("---------------------------------------------")
print()
print()
print("-------------------------------------------------------------------------------")
print()
else:
print("List of Speed Camera Location")
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"):
name = str(input("Enter driver's name: "))
iD = str(input("Enter identification number: "))
phonenum = str(input("Enter phone number: "))
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()
speed = eval(input("The choosen speed: "))
while (speed <= 110):
print("Invalid speed chosen!")
speed = eval(input("The choosen speed: "))
if (speed >= 111) and (speed <= 140):
fine = "150"
merit = "1"
elif (speed >= 141) and (speed <= 159):
fine = "200"
merit = "2"
elif (speed >= 160):
fine = "250"
merit = "Jail"
else:
print("Error!")
print()
print("List of Speed Camera Location: ")
print()
locEndfile = open(constant,"r")
x = locEndfile.readlines()
xcounter = 1
for line in x:
print(xcounter," ",line)
xcounter += 1
locEndfile.close()
loc = str(input("Enter speeding location: "))
while ((eval(loc)) <= 0 ) or ((eval(loc)) > (len(locationlist))):
print("Invalid speeding location!")
loc = str(input("Enter speeding location: "))
if (loc == "1"):
locationspeeding = locationlist[0]
elif (loc == "2"):
locationspeeding = locationlist[1]
elif (loc == "3"):
locationspeeding = locationlist[2]
elif (loc == "4"):
locationspeeding = locationlist[3]
elif (loc == "5"):
locationspeeding = locationlist[4]
elif (loc == "6"):
locationspeeding = locationlist[5]
elif (loc == "7"):
locationspeeding = locationlist[6]
elif (loc == "8"):
locationspeeding = locationlist[7]
elif (loc == "9"):
locationspeeding = locationlist[8]
elif (loc == "10"):
locationspeeding = locationlist[9]
elif (loc == "11"):
locationspeeding = locationlist[10]
else:
print("Error! Please contact technician.")
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("Your offender's data is successfully saved to text file.")
print()
elif(choice == "D"):
print("Here is the record: ")
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"):
print("Thank You for Using The System!")
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):
if (speed >= 111) and (speed <= 140):
fine = "150"
merit = "1"
elif (speed >= 141) and (speed <= 159):
fine = "200"
merit = "2"
elif (speed >= 160):
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("Here is the record: ")
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():
print("Thank You for Using The System!")
def main():
truth = "True"
locationlist = []
while (truth == "True"):
print("--------Traffic OPS Summon----------------")
print("A:View and Edit the camera Location")
print("B:Enter New Speeding offence")
print("C:Record Data")
print("D:Display Speeding Summon File")
print("E:Quit")
print()
choice = str(input("Choice: "))
if (choice != "A") and (choice != "B") and (choice != "C") and (choice != "D") and (choice !=
"E"):
print("Invalid option was entered. Try again.")
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: "))
while (res == "Yes"):
constant = "CameraLocationList.txt"
locfile = open(constant,"a")
location = input("Enter camera location: ")
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("List of Speed Camera Location")
print("---------------------------------------------")
print()
print()
print("-------------------------------------------------------------------------------")
print()
else:
print("List of Speed Camera Location")
print("---------------------------------------------")
viewcameraLoction(constant)
print("-------------------------------------------------------------------------------")
elif(choice == "B"):
name = str(input("Enter driver's name: "))
iD = str(input("Enter identification number: "))
phonenum = str(input("Enter phone number: "))
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()
speed = eval(input("The choosen speed: "))
while (speed <= 110):
print("Invalid speed chosen!")
speed = eval(input("The choosen speed: "))
f,m = speedEvaluation(speed)
print()
print("List of Speed Camera Location: ")
print()
viewcameraLoction(constant)
loc = str(input("Enter speeding location: "))
while ((eval(loc)) <= 0 ) or ((eval(loc)) > (len(locationlist))):
print("Invalid speeding location!")
loc = str(input("Enter speeding location: "))
if (loc == "1"):
locationspeeding = locationlist[0]
elif (loc == "2"):
locationspeeding = locationlist[1]
elif (loc == "3"):
locationspeeding = locationlist[2]
elif (loc == "4"):
locationspeeding = locationlist[3]
elif (loc == "5"):
locationspeeding = locationlist[4]
elif (loc == "6"):
locationspeeding = locationlist[5]
elif (loc == "7"):
locationspeeding = locationlist[6]
elif (loc == "8"):
locationspeeding = locationlist[7]
elif (loc == "9"):
locationspeeding = locationlist[8]
elif (loc == "10"):
locationspeeding = locationlist[9]
elif (loc == "11"):
locationspeeding = locationlist[10]
else:
print("Error! Please contact technician.")
elif(choice == "C"):
saveDataC(name,iD,phonenum,speed,f,m,locationspeeding)
print("Your offender's data is successfully saved to text file.")
print()
elif(choice == "D"):
displayD()
elif(choice == "E"):
exit()
break
else:
print("Invalid syntax!")
truth = "False"
main()