Skip to content

Instantly share code, notes, and snippets.

@jahir
Created September 18, 2019 14:37
Show Gist options
  • Save jahir/bf95f9b1a5318718bc42fa0121f7bb47 to your computer and use it in GitHub Desktop.
Save jahir/bf95f9b1a5318718bc42fa0121f7bb47 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import sys
(darlehen, zinssatz, monatlich) = (float(x) for x in sys.argv[1:])
monate = 0
zinsen = 0.0
while darlehen > 0:
monate += 1
zins = darlehen * zinssatz / 100 / 12
zinsen += zins
darlehen = darlehen - monatlich + zins
# print("%d. Monat: %.2f € übrig, %.2f € Zinsen" % (monate, darlehen, zinsen))
print('Schuldenfrei nach %d Monaten (%d Jahre %d Monate), %.2f € Zinsen bezahlt' % (monate, monate / 12, monate % 12, zinsen))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment