Skip to content

Instantly share code, notes, and snippets.

@MorkHub
Created November 17, 2016 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MorkHub/50c541ed16d1fa466037e203a5a49a4b to your computer and use it in GitHub Desktop.
Save MorkHub/50c541ed16d1fa466037e203a5a49a4b to your computer and use it in GitHub Desktop.
def exercise_04 ():
print(" Exercise 04 - Savings Calculator")
balance = input(" 1. Enter your current balance: ",type=float)
interestPercent = input(" 3. Enter your interest rate (%): ",type=float)
target = input(" 2. Enter number of years: ",type=int)
years = 0
while (years < target):
interest = balance * interestPercent/100
balance = balance + interest
years = years + 1
if not years == target:
print(" Year #%s = £%s" % (years,format(round(balance,2),'.2f')))
balance = round(balance,2)
print (" After %s years = £%s" % (years,format(round(balance,2),'.2f')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment