Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write the python code for the following problem Speeding Violation Calculator #

ID: 3624738 • Letter: W

Question

write the python code for the following problem

Speeding Violation Calculator

# Design a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. the program should ask for the speed limit and the driver's. Validate the input as follows:

. The speed limit should be at least 20, but not greater than 70
. The driver's speed should be at least the value entered for the speed limit( otherwise the driver was not speeding)

Once correct data has been entered, the program should calculate and display the number of miles per hour over the speed limit that the driver was doing.

Explanation / Answer

def checklimit():

actual = input("Enter the offender's speed in mph: ")
limit = input("Enter the speed limit in mph: ")
if (limit > 20) and (limit < 70):

if actual > limit:

print "Driver was going", actual-limit, "mph over the limit."

else:

print "Driver was going at a legal speed."

else:

print 'Invalid speed limit.'