Lesson 01/07 – Before We Begin
[code lang=”python”]
def answer ():
return 42
[/code]
Lesson 02/07 – Planning Your Trip
[code lang=”python”]
def hotel_cost (nights):
return 140 * nights
[/code]
Lesson 03/07 – Getting There
[code lang=”python”]
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
[/code]
Lesson 04/07 – Transportation
[code lang=”python”]
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):
if days < 3:
return 40 * days
elif days > 6:
return 40 * days – 50
else:
return 40 * days – 20
[/code]
Lesson 05/07 – Pull it Together
[code lang=”python”]
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):
if days < 3:
return 40 * days
elif days > 6:
return 40 * days – 50
else:
return 40 * days – 20
def trip_cost (city, days):
return rental_car_cost(days) + hotel_cost (days) + plane_ride_cost (city)
[/code]
Lesson 06/07 – Hey, You Never Know!
[code lang=”python”] def cube(n):
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):
if days < 3:
return 40 * days
elif days > 6:
return 40 * days – 50
else:
return 40 * days – 20
def trip_cost (city, days, spending_money):
return rental_car_cost(days) + hotel_cost (days) + plane_ride_cost (city) + spending_money
[/code]
Lesson 07/07 – Plan Your Trip!
[code lang=”python”]
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):
if days < 3:
return 40 * days
elif days > 6:
return 40 * days – 50
else:
return 40 * days – 20
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)
[/code]