Created
February 12, 2012 07:42
-
-
Save stevekrenzel/1807100 to your computer and use it in GitHub Desktop.
Interest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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