#519 · Python Basics · Beginner · 25 XP · about 3 min
When a bank pays simple interest, your money earns the same amount every year. The interest is worked out with this formula, where rate is the percent paid each year:
interest = principal * rate * years / 100
Write simple_interest(principal, rate, years) that returns the interest earned, rounded to 2 decimal places with round(value, 2).
simple_interest(1000, 5, 2) # returns 100.0 simple_interest(2500, 3.5, 4) # returns 350.0 simple_interest(1200, 4, 0.5) # returns 24.0
In the first example, 1000 dollars at 5 percent earns 50 dollars a year, so 100 dollars in 2 years.
Any of the three numbers can have decimals, and none of them is negative.
First solves only, ranked by stars and then time.