Assignment#2: Taking a Vacation

Assignment#2: Taking a vacation

The code in the following image shows when the function “answer()” is called it”ll return 42.

1111-21

This image shows the function “hotel_cost” with the the argument “nights.” The function must return the cost for the amount of nights stayed at the hotel.

1111-22

The next function defined was “plane_ride_cost(city):”. This function is used to determine the plane ride cost depending on the city being traveled to.

1111-23

Now a third function must be defined which will be called “rental_car_cost(days):”

  • If the car is rented for 2 or less days, the cost is $40 per day(line 15-16).
  • If the car is rented for 7 or more days, there will be a $50 discount(line 17-18).
  • If the car is rented for 3 or more days and 6 or less days, $20 will be taken off the total.

1111-24

Now that the different expenses are put into the program, the trip cost can now be calculated. This can be done by defining the function “trip_cost” with the ariguments “city” and “days,” as shown on line 23. This function will find the sum of the trip expenses.

1111-25

Money may be needed for food, clothes, sourvenirs, etc. In this case, add the argument “spending_money” and the variable “spending_money” should be added to the function “trip_cost.”

1111-26

Finally, the function “trip_cost” must be printed out. the arguments should be one of the four cities, the amount of the days the car will be rented and the amount of spending money available in that specific order as shown in the last line.

1111-27