looking for some solutions? You are welcome.

SOLVED: addressing issues with my basic python Speed ticketing program

roobo:

Hi so I just started learning python at school but haven't understood the teachers teachings and I have started my code bu t run into multiple errors, the program is about someone talking to an online speed ticketing system, it asks how much over the speed limit the person is going and gives the appropriate fines. I am getting errors such as If the person is at the sped limit the code should stop if hes over the code should carry on, and I cnt figure out how when he inputs letters asks fo the question again, This is my second time using stack overflow please dont downgrade for the way I set out the question

warrant = ["Helga Norman", "James Wilson", "Zachary Conroy"]
fine = []
total_fines = 0

"""the check_warrant function uses for loop to
check the list if it matches with the drivers' name"""

def check_warrant(name):
    for person in warrant:
        if person == name:
            print(person.upper(), "IS WANTED FOR ARREST!!!")

#Main Routine
name = input("Enter the name of the driver? :")
check_warrant(name) #calls the check_warrant function and enter the value name

def enterFine():
    global totalFines

    validInput = False
    while validInput == False:
        try:
            speedlimit = int(input("Enter speedlimit :"))#local variables
            if speedlimit >= 0:
                speed = int(input("Enter speed :"))
            amountOver = speed - speedlimit


            if amountOver > 0:
                validInput = True
                print("You are over the speed limit")
                totalFines += 630

            else:
                print("You are driving under the speed limit")
                quit()

        except:
            print("ERROR: Please enter number values only")
#Main Routine
check_warrant(name) 
enterFine()
print("Fine for ", name, "is ", totalFines)

def printSummary():
    print("Total fines:", lens(fines))
    for number in range(0, len(fines)):
        print(number + 1, ") Name: ", fines[number][0], " Speed over limit: in kmph ", fines[number][1])
    print("Total amount of fines: $", totalFines)



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent