122k views
0 votes
write a function interest() that takes one input, a floating-point interest rate (e.g., 0.06, which corresponds to a 6% interest rate). your function should compute and return how long (in years) it will take for an investment to double in value. note: the number of years it takes for an investment to double does not depend on the value of the initial investment.

1 Answer

2 votes

Code:

def interest():

interest_rate = 0.06

investment = input(int('Investment: '))

yield = 0

year = 0

while (yield < investment):

year += 1

yield = investment * interest_rate

print (year)

NOTE: i wrote this code assuming that the investment for the next year is the same as the first year and so forth

User Steve Baker
by
8.5k points

No related questions found