Answer to Question #128979 in Python for Jay Patel

Question #128979
Create a program that takes the speed limit and speed of the car an issues a warning or a fine:
A warning if the speed is 5% above the speed limit.
A fine of £500 if the speed is 10% above the limit.
1
Expert's answer
2020-08-11T10:41:59-0400
def CheckSpeed(speed_limit, car_speed):
    if car_speed > speed_limit * 1.1:
        print("Fine 500 GBP: speed is 10% above the limit")
    elif car_speed > speed_limit * 1.05:
        print("Warning: speed is 5% above the limit")

# TEST
if __name__ == "__main__":
    speed_limit = 200
    normal_speed = 100
    warning_speed = 215
    fine_speed = 250
  
    CheckSpeed(speed_limit, normal_speed)
    CheckSpeed(speed_limit, warning_speed)
    CheckSpeed(speed_limit, fine_speed)

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