Last active
August 29, 2015 14:17
-
-
Save fabian57/dafea7f56d35fcc33a10 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
DATA = { | |
"A": {"unlimited": 70, "package": 50, "extra_mile": 1}, | |
"B": {"unlimited": 140, "package": 100, "extra_mile": 1.5}, | |
} | |
DAILY_MILEAGE_LIMIT = 200 | |
mileage = input("Mileage? ") | |
duration = input("Duration (days)? ") | |
category = raw_input("Category (A or B)? ").upper() | |
price_unlimited = duration * data[category]["unlimited"] | |
price_package = duration * data[category]["package"] | |
extra_miles = mileage - duration * DAILY_MILEAGE_LIMIT | |
if extra_miles > 0: | |
price_package += extra_miles * data[category]["extra_mile"] | |
print "Best option:", | |
if price_unlimited < price_package: | |
print "unlimited ($%s)" % price_unlimited, | |
else: | |
print "package ($%s)" % price_package, | |
print "that is to say $%s saving" % abs(price_unlimited - price_package) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parfait!
Regarde le commentaire du programme d'Étienne pour la version longue ;)