[Tutor] Concerning Programming Exercise #6 of Chapter 2 of Python Programming John Zelle Textbook

Mark Tolonen metolone+gmane at gmail.com
Wed Jan 21 04:18:11 CET 2009

Since you are updating the principal value each year, use the following to grow the principal by the interest rate each year:

principal = principal * (1 + apr)

  "bob gailer" <bgailer at gmail.com> wrote in message news:49761FDC.5020800 at gmail.com...
  Donna Belle Ibarra wrote: 
    Hi! I need help with program exericse #6 entitled "Futval.py" which is a program that computes the value of an investment carried 10 years into the future.

    This is the coding I have.. yet it does not seem to spit out the correct numbers (Am I using an incorrect equation?)

  Take a look at http://en.wikipedia.org/wiki/Time_value_of_money#Present_value_of_a_future_sum for the various formulas. I am not sure which applies in your case.

    def main():
        print "This program calculates the future value"
        print "of a 10-year investment."

        principal = input("Enter the amount invested each year: ")
        apr = input("Enter the annual interest rate: ")
        years = input("Enter the number of years: ")

        for i in range (1, years + 1):
            principal = principal * (1 + apr)**i
            print "The value in", i, " years is:", principal


    The output is suppose to appear like this:

    This program calculates the future value of a 10-year investment.
    Enter the amount invested each year: 100.00
    Enter the annual interst rate: 0.05
    Enter the number of years: 10
    The value in 1 years is 105.0
    The value in 2 years is 215.25
    The value in 3 years is 331.0125
    The value in 4 years is 452.563125

    And so on..

    ^Please help me!!!

Tutor maillist  -  Tutor at python.org

  Bob Gailer
  Chapel Hill NC


  Tutor maillist  -  Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090120/00c04938/attachment.htm>

More information about the Tutor mailing list