I am not sure how to set up the for loops for this problem to print the table. H
ID: 643144 • Letter: I
Question
I am not sure how to set up the for loops for this problem to print the table. Help please. *67 (Financial application: compute the future investment value) Write a function that computes a future investment at a given interest rate for a specified number of year. The future investment is determined using the formula in Exercise 2.19 Use the following function header: For example. futurelnvestmentValue(10000, 0.05/12, 5) returns 12833. 59. Write a test program that prompts the user to enter the investment amount and the annual interest rate in percent and prints a table that displays the future value for the years from 1 to 30. Here is a sample run:
Explanation / Answer
import math
def futureInvestmentValue(investmentAmount, monthlyInterestRate, years):
print('Years Future Value')
for i in range(1, years + 1):
investmentAmount *= math.pow((1 + monthlyInterestRate), 12)
print(str(i) + ' ' + str(round(investmentAmount, 2)))
def main():
amount = float(input('The amount invested: '))
rate = float(input('Annual interest rate: '))
futureInvestmentValue(amount, rate / 1200, 30)
main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.