Hey, you never know (Taking a Vacation)


#1



https://www.codecademy.com/courses/python-beginner-P5YtY/1/5?curriculum_id=4f89dab3d788890003000096



None


im stuck


def hotel_cost(nights):
    return 140.0 * nights
    
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):
    cost = days * 40
    if days >= 7:
       cost -= 50
    elif days >= 3:
       cost -= 20
    return cost    
 
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 spending_money(place):
    if city == "Charlotte":
        return 123
    elif city == "Tampa":
        return 124
    elif city == "Pittsburgh":
        return 125
    elif city == "Los Angeles":
        return 126
    
def trip_cost(city, days, place):
    return plane_ride_cost(city) + hotel_cost(days) + spending_money(place)

print trip_cost


#3

def hotel_cost(nights):
return 140 * nights
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):
if days >= 7:
return days * 40 - 50
elif days >= 3:
return days * 40 - 20
else:
return days * 40
def trip_cost(city, days, spending_money):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money


#4

should change "city" into "place"


#5

Here's my code:

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

print trip_cost("Los Angeles", 5, 600)

#6

what do u think is wrong with my code???????

def hotel_cost(nights):
return 140.0 * nights

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):
cost = days * 40
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost

def spending_money(place):
if city == "Charlotte":
return 123
elif city == "Tampa":
return 124
elif city == "Pittsburgh":
return 125
elif city == "Los Angeles":
return 126

def trip_cost(city, days, place):
trip_cost = plane_ride_cost(city) + hotel_cost(days)
return trip_cost + spending_money(place)


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.