Taking a Vacation

I A Review of Function Creation

i. Before We Begin 1/7

def answer():
    return 42

II Planes, Hotels and Automobiles

i. Planning Your Trip 2/7

def hotel_cost(n):
    return n*140

ii. Getting There 3/7

def hotel_cost(n):
    return n*140

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

iii. Transportation 4/7

def hotel_cost(n):
    return n*140

def plane_ride_cost(city):
    if city == "Charlotte":
        return 183
    elif city == "Tampa":
        return 220
    elif city == "Pittsburgh":
        return 222
    elif city == "Los Angeles":
        return 475
def rental_car_cost(days):
    rent = 40*days
    if days >= 7:
        rent = rent - 50
    elif days >= 3:
        rent = rent - 20
    else:
        rent
    return rent

iv. Pull it Together 5/7

def hotel_cost(days):
    return days*140
def plane_ride_cost(city):
    if city == 'Charlotte':
        return 183
    elif city == 'Tampa':
        return 220
    elif city == 'Pittsburgh':
        return 222
    elif city == 'Los Angeles':
        return 475
def rental_car_cost(days):
    rent = 40*days
    if days >= 7:
        return rent - 50
    elif days >= 3:
        return rent - 20
    else:
        return rent
def trip_cost(city,days):
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)

v. Hey, You Never Know! 6/7

def hotel_cost(days):
    return days*140
def plane_ride_cost(city):
    if city == 'Charlotte':
        return 183
    elif city == 'Tampa':
        return 220
    elif city == 'Pittsburgh':
        return 222
    elif city == 'Los Angeles':
        return 475
def rental_car_cost(days):
    rent = 40*days
    if days >= 7:
        return rent - 50
    elif days >= 3:
        return rent - 20
    else:
        return rent
def trip_cost(city,days,spending_money):
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money

vi. Plan Your Trip! 7/7

def hotel_cost(days):
    return days*140
def plane_ride_cost(city):
    if city == 'Charlotte':
        return 183
    elif city == 'Tampa':
        return 220
    elif city == 'Pittsburgh':
        return 222
    elif city == 'Los Angeles':
        return 475
def rental_car_cost(days):
    rent = 40*days
    if days >= 7:
        return rent - 50
    elif days >= 3:
        return rent - 20
    else:
        return rent
def trip_cost(city,days,spending_money):
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money
print trip_cost('Los Angeles',5,600)
    
Advertisements

One thought on “Taking a Vacation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s