Problem 135126 · easy · Level 01 Prerequisites & Setup

Savings Account Balance

functions · percentages · powers

A savings account pays rate percent interest once a year, added to the balance. Write compound_balance(principal, rate, years) that returns the balance after years years, rounded to 2 decimal places.

Examples

Input:  principal = 1000, rate = 5, years = 2
Output: 1102.5
Explanation: 1000 -> 1050 -> 1102.5

Input:  principal = 500, rate = 10, years = 1
Output: 550.0

Input:  principal = 1000, rate = 0, years = 10
Output: 1000.0

Constraints

  • 0 <= principal <= 10**6
  • 0 <= rate <= 100 (may be a float)
  • 0 <= years <= 100

Goals

  • Turn a percentage rate into a growth factor
  • Use `**` for repeated growth
  • Round money to 2 decimals
Starting Python…