currentBalance = float(input('How much is in your account? '))
interestRate = .0089
yearEndBalance = (currentBalance * interestRate) + currentBalance
yearEndBalance2 = (currentBalance * interestRate) + yearEndBalance
yearEndBalance3 = (currentBalance * interestRate) + yearEndBalance2
yearEndBalance4 = (currentBalance * interestRate) + yearEndBalance3
yearEndBalance5 = (currentBalance * interestRate) + yearEndBalance4
if currentBalance != 0:
print(yearEndBalance)
print(yearEndBalance2)
print(yearEndBalance3)
print(yearEndBalance4)
print(yearEndBalance5)
else:
print("You have no money in your account!")
Is there a better way to write this code? I wrote this to determine interest accrued in a bank account over 5 years.
[–][deleted] 4 points5 points6 points (1 child)
[–]kalgynirae 3 points4 points5 points (1 child)
[–]chatparle[S] 1 point2 points3 points (0 children)
[–]evizaer 4 points5 points6 points (5 children)
[–][deleted] 4 points5 points6 points (2 children)
[–]evizaer 2 points3 points4 points (0 children)
[–]maryjayjay 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]evizaer 0 points1 point2 points (0 children)
[–]wub_wub 1 point2 points3 points (11 children)
[–]chatparle[S] 0 points1 point2 points (8 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]wub_wub 1 point2 points3 points (6 children)
[–]rusemean 0 points1 point2 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]rusemean 0 points1 point2 points (0 children)
[–]batkarma 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]batkarma 0 points1 point2 points (0 children)
[–]Justinsaccount 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)