Problem 107122 · easy · Level 01 Prerequisites & Setup

Percentage Change

functions · percentages · rounding

A shop tracks how prices move. Write percent_change(old, new) that returns the percentage change from old to new, rounded to 1 decimal place. A decrease is negative.

Examples

Input:  old = 50, new = 75
Output: 50.0

Input:  old = 80, new = 60
Output: -25.0

Input:  old = 200, new = 200
Output: 0.0

Constraints

  • 1 <= old <= 10**6
  • 0 <= new <= 10**6
  • Return a float rounded with round(x, 1).

Goals

  • Apply the percentage-change formula
  • Round a float to a fixed number of decimals
Starting Python…