Skip to content

Instantly share code, notes, and snippets.

@stevekrenzel
Created February 12, 2012 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stevekrenzel/1807100 to your computer and use it in GitHub Desktop.
Save stevekrenzel/1807100 to your computer and use it in GitHub Desktop.
Interest
from sys import argv, exit
types = {
'simple': lambda capital, rate, time: capital * (1 + (rate * time)),
'compound': lambda capital, rate, time: capital * ((1 + rate) ** time)
}
if len(argv) != 5 or argv[1] not in types:
print "usage: %s <%s> capital rate time" % (argv[0], '|'.join(types))
exit(1)
capital, rate, time = map(float, argv[2:])
print types[argv[1]](capital, rate, time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment