In: Computer Science
Write a function for checking the speed of drivers. This function should have one parameter: speed.
1. If speed is less than 70, it should print “Ok”.
2. Otherwise, for every 5km above the speed limit (70), it should give the driver one demerit point and print the total number of demerit points. For example, if the speed is 80, it should print: "Points: 2". 3. If the driver gets more than 12 points, the function should print: “License suspended”
python language
Hide comments (1)
Python code:
#defining function to check speed
def speedCheck(speed):
    #checking if speed is less than 70
    if(speed<70):
        #priniting OK
        print("OK")
    else:
        #finding the number of
points
       
point=(speed-70)//5
        #printing it
       
print("Points:",point)
        #checking if it is
greater than 12
        if(point>12):
           
#printing License suspended
           
print("License suspended")
#calling speedCheck function for a sample value 150
speedCheck(150)
Screenshot:

Output:
