7/7 trip_cost is not precise


#1

hotel_cost (nights) here the argument is "nights"

trip_cost(city,days,spending_money) here we consider only days and not nigths in the arguments

Hence this program will not work for a 3 day and 2 night trip
Its limited to trips with equal days and nights

:smile:


#2

Hi, @designace84849 ,

The length of the trip, in terms of days, is considered to be the same as the number of nights of the stay, even though a two-night trip includes parts of three different days. So, even through the header of the hotel_cost function is ...

def hotel_cost(nights):

... you will be able to call the function with hotel_cost(days).


#3

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)