177k views
25 votes
An amount of money P is invested in an account where interest is compounded at the end of the period. The future worth F yielded at an interest rate i after n periods may be determined from the following formula: 

F=P(1+i)n.F=P(1+i)n.
Write a program that will calculate the future worth of an investment for each year from 1 through n. The input to the function should include the initial investment P, the interest rate i (as a decimal), and the number of years n for which the future worth is to be calculated. The output should consist of a table with headings and columns for n and F. Run the program for P = $100,000, i=.05, n=10 years F=P(1+i)nF=P(1+i)n

Modify the problem by using the following general formula for compounding interests: F=P(1+i/m)^mn where, m is the number of interest payments per year. Solve the problem for m=1 (annual) and m=12 (monthly).

User Diogojme
by
2.9k points

1 Answer

8 votes

Answer:

def future_worth(p,i,n):

print("n \t F")

for num in range(1, n+1):

F = round(p * ((1 + i)** num), 2)

print(f"{num}\t{F}")

future_worth(100000, .05, 10)

Step-by-step explanation:

The "future_worth" function of the python program accepts three arguments namely the P (amount invested), i (the interest rate), and n (the number of years). The program runs a loop to print the rate of increase of the amount invested in n number of years.

User Tomasbedrich
by
3.4k points