Taking a Vacation

hw2-1 hw2-2 hw2-3 hw2-4 hw2-5 hw2-6 hw2-7

This lab, “Taking a Vacation”, focuses on teaching students on using functions in coding to plan for a trip. Students are to use the def command to define a function with a variable, example the variable of hotel_cost is nights. They will also learn the usage of if, elif, and else to provide the function with different values for the variable by setting in different options and meanings, example: 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

They will learn also how to change the function of the value by adding in certain conditions to change it like say if there is more than 7 blanks, reduce the total value by 35.
Example: def rental_car_cost (days):
rental_car_cost = 40 * days
if days >= 7:
rental_car_cost -= 50
elif days >= 3:
rental_car_cost -= 20
return rental_car_cost

After that, they can create a function that combines all of those functions together to create one big function that equals the sum of the functions put together. This makes it simple to get the total amount of money spent on the whole trip without having to do it all separately.