Created
November 17, 2016 23:38
-
-
Save MorkHub/50c541ed16d1fa466037e203a5a49a4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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