Skip to content

Instantly share code, notes, and snippets.

@spaghettiSyntax
Created December 6, 2017 07:15
Show Gist options
  • Save spaghettiSyntax/68e6b2596696ca06aedd81acdd87a1a4 to your computer and use it in GitHub Desktop.
Save spaghettiSyntax/68e6b2596696ca06aedd81acdd87a1a4 to your computer and use it in GitHub Desktop.
Tony Gaddis Python: Compound Interest
#ch_2_jrn_4
#Exercise 14
#This program calculates
#Compound Interest
print(' ')
print('Calculate compound interest by inputting values.')
print(' ')
print('Your initial deposit to your account.')
principal = float(input('Principal Deposit: '))
print(' ')
print('Input annual percentage rate example-')
print('10 for 10% without the symbol and not dividing to 0.1.')
rate = float(input('Enter Annual Interest Rate Percentage: '))
print(' ')
print('Compound interest example-')
print('12 for monthly, 4 for quarterly, or 1 for annually.')
compound = float(input('Annual Compound Frequency: '))
print(' ')
print('Number of years you would like to compound your interest?')
time = float(input('Years: '))
print(' ')
accrual = principal * (1.0 + ((rate / 100)/ compound)) ** (compound * time)
print('Amount compounded after', time, 'years is: ', format(accrual, '.2f'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment