Review: Modules


#1

ef hotel_cost(nights):
    return 140*nights
def plane_ride_cost(city):
    if plane_ride_cost(city)=="Charlotte":
        return 183
    elif plane_ride_cost(city)=="Tampa":
        return 2220
    elif plane_ride_cost(city)=="Pittsburgh":
        return 222
    elif plane_ride_cost(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 40


#2

it should be "def" not "ef"


#3

my code, don't forget the indentations!:

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

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


#4

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