id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > interest
prev  |  next  |  chance

Suppose you put some initial amount into the bank and you get a fixed interest rate compounded annually (e.g. initial might be 1000, and the rate might be 3% for example). Write a function interest(amount, rate, target) that takes the initial amount, the interest rate, and the target amount as parameters. The function should use a while loop to determine how long will it take for your account to have at least target amount in it (e.g. target = 1200). The function should return the number of years it takes to reach the target amount. Return this number as an integer (use the int() function) to avoid issues with numerical approximation. Side note: because compounding happens once per year the APR is equal to the APY in this case.


interest(1000, 0.03, 1200) → 7
interest(1000, 0, 200) → 0
interest(1500, 0.1, 2000) → 4

...Save, Compile, Run (ctrl-enter)

def interest(amount, rate, target):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy