Problem 177576 · easy · Level 01 Prerequisites & Setup

Speeding Fine

conditionals · arithmetic · boolean flags

Write speeding_fine(speed, limit, school_zone) that computes a fine from how far a driver was over the speed limit:

  • not over the limit: 0
  • 1 to 10 over: 50
  • 11 to 20 over: 100
  • more than 20 over: 200

In a school zone (school_zone is True) every fine is doubled.

Examples

Input:  speed = 60, limit = 50, school_zone = False
Output: 50

Input:  speed = 75, limit = 50, school_zone = True
Output: 400

Input:  speed = 45, limit = 50, school_zone = False
Output: 0

Constraints

  • 0 <= speed, limit <= 300 (integers)

Goals

  • Classify by the difference between two numbers
  • Double a result under an extra condition
Starting Python…