Answer to Question #252631 in Python for maith

Question #252631

• Write a function for checking the speed of drivers. This function

should have one parameter: speed.

• If speed is less than 70, it should print "Ok".

• 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"

• If the driver gets more than 12 points, the function should print:

"License suspended"


1
Expert's answer
2021-10-17T09:35:03-0400
def check_speed(speed):
    if speed <= 70:
        return 'Ok'
    elif speed >= 70:
        points = (speed - 70) // 5
        print('points = {}'.format(points))
        if points >= 12:
            return 'License suspended'
check_speed(80)
points = 2

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS