there are six errors in this code debug this code- #Determining a Speeding Ticke
ID: 3836586 • Letter: T
Question
there are six errors in this code
debug this code-
#Determining a Speeding Ticket
#This program will determine the cost of a speeding ticket, if there is on,
#based upon the speed limit and the clocked speed.
#Declare Variables
ClockSpeed = float()
SpeedLimit = float()
Difference = float()
Fine = float()
#Get clock speed and speed limit from the user
SpeedLimit = input("Enter the Speed Limit: ")
ClockSpeed = float(input("Enter the Clock Speed: ")
#Determine the difference between clock speed and speed limit
Difference = SpeedLimit - ClockSpeed
#Determine if there is a violation
if Difference <= 0:
print("You are going the speed limit and do not get a ticket!")
else:
if Difference <= 5:
Fine = 110
if Difference <= 10:
Fine = 120
if Difference <= 15:
Fine = 140
if Difference <= 20:
Fine = 160
else:
Fine = 110 + (Difference * 5)
print("Sorry you are getting a ticket!")
print("The Ticket Amount is: $" + Fine)
list of possible mistakes
e variable SpeedLimit needs to be declared as a string If structure logic to determine the amount of the ticket is wrong. Needs to be rewritten as a alternative structure mull The print statement print ("Sorry you are getting a ticket!) needs to be de indented and aligned with the margin Missing float() ea If structure underneith else: needs to be indented ClockSpeed and SpeedLimit need to be reversed The print statement print ("The Ticket Amount is: Fine needs to remove the plus symbol and replace it with a comma The n the IF Difference statement needs to be The float() function needs to be removed from the ClockSpeed input statement There needs to be an else statement in between IF Difference 5 and Difference 10 Missing ending The else statement under IF Difference 0 needs to be removedExplanation / Answer
If structure underneath else needs to be indented
The if structure logic is wrong and needs to be rewritten as a multi alternative structure
The <= in if Difference should be >=
Missing float() for input of speed limit
Clockspeed and speedlimit needs to be reversed
Missing ending bracket for ClockSpeed = float(input("Enter the Clock Speed: ")
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.