# 6/7 help

#1

def hotelcost(nights):
return 140*nights
def planeridecost(city):
if (city) == "Charlotte":
return 183
if (city) == "Tampa":
return 220
if (city) == "Pittsburgh":
return 222
if (city) == "Los Angeles":
return 475
else:
print "invalid"
def rentalcarcost(days):
if days >= 7:
return days40 - 50
elif days >= 3:
return days40 - 20
else:
return days * 40
def tripcost(city,days,spendingmoney):
return planeridecost(city) + rentalcarcost(days) + spendingmoney

#2

Is this right????????????

#3

You didnt add the cost of the hotel at the end
Also you didnt create a 'cost' function inside the rental car cost to get the cost of it each day
it cost \$40 each day for the rental so it takes 40 * amount of days you rent it for
then in the if statement it takes the total of that and if its greater or equal to 7(7 days) you get a \$50 off discount,
else if its greater or equal to 3(3 days) you get a \$20 off discount

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
elif(city == "Los Angeles"):
return 475

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

def trip_cost(city, days, spending_money):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money``````

#4

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 < 7:
return days * 40 - 20
else:
return days * 40

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