Kritik af Python kode
Jeg er Python novice og har skrevet en kode til lån af bank, kritér.from math import pow
from decimal import *
def round(x):
x = Decimal(x).quantize(Decimal('.01'), rounding=ROUND_DOWN)
return x
def myprint(s, i):
print s, '{:>8}'.format(i)
def ncl(r, t, k, a):
y = 0
k = k + k * .02 + 600
terminer = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]
for y in range(0, t * 12):
y = y + 1
if y / 12 >= t:
print " Lånet er ikke holdbart"
return
if k >= 700:
if terminer.count(y):
kr = k * r
k = k + kr - a
myprint("Termin nr:\t", y / 12)
myprint("Måned:\t\t", y)
myprint("Renten:\t\t", round(kr))
myprint("Kapital:\t", round(k))
myprint("Afdrag:\t\t", round(a))
elif not terminer.count(y):
k = k - a
myprint("Måned:\t\t", y)
myprint("Kapital:\t", round(k))
myprint("Afdrag:\t\t", round(a))
elif k < 700:
if terminer.count(y):
kr = k * r
k = k + k * r - a
myprint("Termin nr:\t", y / 12)
myprint("Måned:\t\t", y)
myprint("Renten:\t\t", round(kr))
myprint("Kapital:\t", round(k))
myprint("Afdrag:\t\t", round(a))
elif not terminer.count(y):
k0 = k
k = k - k
myprint("Måned:\t\t", y)
myprint("Kapital:\t", round(k))
myprint("Afdrag:\t\t", round(k0))
if k <= 0:
print "Lånet er tilbagebetalt"
return
ren = 0.11
ter = 10
kap = 15000
afd = 700
ncl(ren, ter, kap, afd)