Taking a vacation: Hey, You never know. :( HELP MEE


#1



help me please im stuck :confused:


taking a vacation: Hey, you never know.


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


#2

you had this function:

def trip_cost(city, days):

now you needed to add spending money:

def trip_cost(city, days, spending_money):

and simply add it to the function content:

return plane_ride_cost(city) + hotel_cost(days) + spending_money

that is all. No need to create additional function (remove the spending money function)


#3

Oh, i just am terrible at coding :slight_smile: Thanks for the help, i'll see if it works (meaning if i can understand it xD)


#4

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, spending_money):
    return plane_ride_cost(city) + hotel_cost(days) + spending_money

print trip_cost

#5

Oops, try again. trip_cost('Tampa', 4, 0) returned 780.0 instead of the correct value 920


#6


None


#7

< function trip_cost at 0x7fee63232398 >
None


#8

Oops, try again. trip_cost('Los Angeles', 8, 0) returned 1595.0 instead of the correct value 1865


#9

Oops, try again. trip_cost('Charlotte', 7, 0) returned 1163.0 instead of the correct value 1393


#10

Thats my code and those are the 3 error messeges Does Facepalm


#11

here:

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

remove this code, you have the trip_cost twice, and spending money is not depending on the city.

finally here:

return plane_ride_cost(city) + hotel_cost(days) + spending_money

you forgot to rent a car.

and one final tip:

print trip_cost

if you where to provide arguments at a function call, you can actually see what is happening, instead of being told it is a function


#12

Lol Oops ... /\/\AAaaahhh


#13

Ive reset my code 10-15 times, i need to figure out how to do what the instructions say...

def hotel_cost(nights):
# If the hotel costs $140/night...
    return 140 * nights
def plane_ride_cost(city):
# Statements below provide cost of plane ticket for 4 different cities
    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):
# Statements below provide cost of rental car per day with 7 and 3-day discounts
    car_cost = 40 * days
    if days >= 7:
        car_cost -= 50
        return car_cost
    elif days >= 3:
        car_cost -= 20
        return car_cost
    elif days < 3:
        return car_cost
def trip_cost(city, days):
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)

#15

now your spending_money went missing, you are so clos each time


#16

2 posts were split to a new topic: You never know


#17

def hotel_cost(nights):
# If the hotel costs $140/night...
    return 140 * nights
def plane_ride_cost(city):
# Statements below provide cost of plane ticket for 4 different cities
    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):
# Statements below provide cost of rental car per day with 7 and 3-day discounts
    car_cost = 40 * days
    if days >= 7:
        car_cost -= 50
        return car_cost
    elif days >= 3:
        car_cost -= 20
        return car_cost
    elif days < 3:
        return car_cost
def trip_cost(city, days, spending_money):
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money()
#its my new code... cant figure it out... still...

#18

Hmmph Help me please...


#19

spending_money()

spending_money is not a function call!


#21

What is a function call???
Yea.. I don't know these things...


#22

Oh im stupid... I HAD TO REMOVE THE "()" AT THE END... WHY DIDN'T I TRY THIS ~ Th3b33