Skip to content

Instantly share code, notes, and snippets.

@zoeyfyi
Created February 27, 2017 12:59
Show Gist options
  • Save zoeyfyi/ebef7dc5b90320f687f6b6151543a763 to your computer and use it in GitHub Desktop.
Save zoeyfyi/ebef7dc5b90320f687f6b6151543a763 to your computer and use it in GitHub Desktop.
year = 2017
rpi = 0.02
inflation = 0.027778
maintance = 8570
start_fee = 9250
def loan(target, maint=maintance):
return (start_fee * (1 + inflation) ** (target - year)) + maint
def total_fee(year, accum=0):
return (accum + loan(year)) * (1 + rpi)
def total(start, end):
accum = 0
current_year = start
while end+1 > current_year:
accum = total_fee(current_year, accum)
current_year += 1
return accum
wipe = 30
salery = 40000
rate_increase = 0.05
def years(amount, start_salery=salery):
y = 0
pay_sum = 0
while y < 30 and amount > 0:
# Intrest
amount += amount * inflation
# Pay off
pay_off = start_salery * 0.09
pay_sum += pay_off
amount -= pay_off
start_salery += start_salery * rate_increase
y+=1
if amount < 0:
amount = 0
return y, amount, pay_sum
for i in range(4):
start = 2017 + 4 * i
end = start + 4
print(str(start) + " - " + str(end))
after_uni = total(start, end)
print("Total debt after uni: " + str(after_uni))
yy, amount, pay_sum = years(total(start, end))
print("In " + str(yy))
@tpb1908
Copy link

tpb1908 commented Feb 28, 2017

9% is only paid on > £21000, so that should be subtracted from the salary value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment