codeacademy python course series 1

So, I was doing this python course in CodeAcademy to complete each section I need to complete a  project which is pretty interesting. Here I am sharing how I solved the problem. For your reference I am giving the instructions as well.

Problem: 

Plan Your Trip!

Nice work! Now that you have it all together, let's take a trip.
What if we went to Los Angeles for 5 days and brought an extra 600 dollars of spending money?

Instructions 

After your previous code, print out the trip_cost( to "Los Angeles" for 5 days with an extra 600 dollars of spending money.
Don't forget the closing ) after passing in the 3 previous values!


Solution

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:
        cost = cost - 50
       
    elif days >= 3:
        cost = cost - 20
       
    else:
        print('You cannot get both of the above discounts.')
    return cost
   
def trip_cost(city,days,spending_money):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money
   
print (trip_cost("Los Angeles",5,600))

**Source: www.codecademy.com

Labels: , , ,