Quotes help make search much faster. Example: "Practice Makes Perfect"

Tuesday, November 27, 2012

Codecademy: Coming Back Home


#sample solution


def hotelCost(days):
return 140*days

def planeRideCost(city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
elif city == "Los Angeles":
return 475

def rentalCarCost(days):
cost = days*40
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost

def tripCost(city,days,cash=0):
return cash+\
rentalCarCost(days)+\
hotelCost(days)+\
planeRideCost(city)

# You were planning on taking a trip to LA for 5 days
# with $600 of spending money.
print tripCost("Los Angeles",5,600)

actualCost = 2734.23
overBudget = actualCost - tripCost("Los Angeles",5,600)
print overBudget

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts