Taking a Vacation

After the completion of the function tutorial, we started off by defining the function hotel_cost with an argument days as an input, since the hotel cost 140 a night we made a return value. Below the existing code we defined the function plane_ride_cost that takes a string city. Then allowing the function to return a different price depending on the location, as shown in the screen shot. Defining another function called rental_car_cost with an argument called days. Next we had to calculate the cost of renting the car, which cost $40 per day. The car rental also featured a rental for 7 or more days will receive $50 off total, else if the car is rented for 3 or more day we will receive $20 off the total. Defining a new function trip_cost that takes two arguments city and days. Next we returned the sum of the 3 passed defined functions. Modifying the trip_cost function we added a third argument spending_money, Then we added the variable spending_money to the sum it returns, Lastly we got the total cost of our trip going to Los Angeles for 5 days and brought $600 of spending money.

 

Plan your trip

Leave a Reply

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