## Python Annuity Calculator

For the discussion of Perl, Python, Ruby, and PHP and other interpreted languages.

### Python Annuity Calculator

Here is my first program in python. It is a annuity calculator for a future value annuity. I feel so good so now I get my annuity homework done like that with out a calc

Code: Select all
`def AnnuityForm():        principle=input("Please Enter Your Principle(Must Contain Cents): ")     time=input("Please Enter How Long The Annuity Is: ")     interest=input("Please Enter Your Interest Rate: ")     tcompounded=input("Please Enter The Amount of Times It Is Compounded A Year: ")     #Configuring n and i for principle forumla    interest=interest/100.00    interest=interest/tcompounded    n=tcompounded*time    #The principle formula    part1=(1.00+interest)**n    part2=part1-1.00    part3=part2/interest    total=part3*principle    #Amount of money deposited        deposited=principle*time*tcompounded    #Total interest gained    ttlinterest=total-deposited        print ""    print "Your final amount is \$",total    print ""    print "The amount you deposited is \$",deposited    print ""    print "The amount of interest you gained is \$",ttlinterest    print ""    print ""    AnnuityForm()AnnuityForm()`
There are 10 kinds of people in this world:

People who understand binary
People who don't

Ajax478
New User

Posts: 10
Joined: Sat Apr 11, 2009 7:33 pm
Blog: View Blog (0)

### Re: Python Annuity Calculator

You don't really need to put it all in a function, but it still works.

YayPython
Experienced User

Posts: 50
Joined: Sat Jan 31, 2009 11:05 am
Blog: View Blog (0)

### Re: Python Annuity Calculator

Well thats only because I wanted it to repeat because when I have to put in multiple problems one after another. If there is another way of doing that without functions please tell me thank you.
There are 10 kinds of people in this world:

People who understand binary
People who don't

Ajax478
New User

Posts: 10
Joined: Sat Apr 11, 2009 7:33 pm
Blog: View Blog (0)

### Re: Python Annuity Calculator

you can do it with some sort of loop.

you could set it up like this (psuedocode, i don't know python)

Code: Select all
`function Enterdata(){// enter data here?}while(true)// keep looping until killed{EnterData()// possibly ask user if they want to enter data again}`

the way i believe you're doing it is a crude form of recursion, which is kinda bad practice.
The whole secret of existence is to have no fear. Never fear what will become of you, depend on no one. Only the moment you reject all help are you freed.
--Buddha

mischief
Poster

Posts: 355
Joined: Wed Jan 07, 2009 4:16 pm
Blog: View Blog (0)

### Re: Python Annuity Calculator

Ah I see. Thanks guys. It works right now so I'll use it becuase I still need to do homework XD. But I will fix it later.
There are 10 kinds of people in this world:

People who understand binary
People who don't

Ajax478
New User

Posts: 10
Joined: Sat Apr 11, 2009 7:33 pm
Blog: View Blog (0)

Return to Interpreted Languages

### Who is online

Users browsing this forum: No registered users and 0 guests