Lab 5: Taking a Vacation

lab description: In this lab we got more experience understanding python strings and lists.

Codes:

def hotel_cost(nights):
if nights>0:
print nights*140
return nights*140
elif nights==0:
print 0
return 0
city = raw_input(“Enter city name”)
def plane_ride_cost(city):
if city == “Charlotte”:
return 183
elif city == “Tampa”:
return 220
elif city == “Pittsburgh”:
return 222
else:
city == “Los Angeles”
return 475
print plane_ride_cost(city)
def rental_car_cost(days):
c = 40
if days >= 7:
return c * days – 50
elif days >= 3:
return c * days – 20
else:
return c * days
def hotel_cost(nights):
return 140 * nights
def hotel_cost(days):
return 140 * days

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 -= 50
elif days >=3 and days < 7:
cost -= 20
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)

Screenshot:

Screen Shot 2015-03-19 at 6.38.11 PM

Leave a Reply

Your email address will not be published. Required fields are marked *