Question
1. Write a Python function, tripCost(distanceMeters , vehSpeedMPS, vehKPL, gasCostPerLiter, hotelCostPerNight, breakfastCostPerDay, lunchCostPerDay, dinnerCostPerDay) that returns the cost of a trip of based on several
1. Write a Python function, tripCost(distanceMeters , vehSpeedMPS, vehKPL, gasCostPerLiter, hotelCostPerNight, breakfastCostPerDay, lunchCostPerDay, dinnerCostPerDay) that returns the cost of a trip of based on several parameters The function's parameters are:
distanceMeters: the trip's distance in meters (type: float)
vehSpeedMPS: the vehicle's speed during the trip, in meters per second (type: float)
vehKPL: the vehicle fuel efficiency in kilometers per liter (type: float)
gasCostPerLiter: the price of one liter of gas in dollars (type: float)
hotelCostPerNight: cost of one night in a hotel in dollars (type: float)
breakfastCostPerDay: cost of a day's breakfast in dollars (type: float)
lunchCostPerDay: cost of a day's lunch in dollars (type: float)
dinnerCostPerDay: cost of a day's dinner in dollars (type: float)
Presume that you can only drive 8 hours per day. So, if a trip requires 15.25 hours, it will require a one-night hotel stay at an additional cost (beyond gas and food costs) equal to hotelCostPerNight. Important notes on cost:
No hotel is needed on the day a trip ends. If a trip requires 8.0 hours, it does not require a hotel stay. Similarly, a trip of 16.0 hours requires one night of hotel, not two.
No breakfast is needed on the first day of a trip.
No dinner is needed on the final day of a trip.
Lunch is needed only on days with more than 4.0 hours of driving.
2. Write a Python function, chooseVehicleForTrip(distanceMiles, veh1Name, veh1SpeedMPH, veh1MPG, veh2Name, veh2SpeedMPH, veh2MPG, gasCostPerGallon, hotelCostPerNight, breakfastCostPerDay, lunchCostPerDay, dinnerCostPerDay) that computes the cost of a trip for two different vehicles, prints information about the cost, and prints a recommendation which vehicle should be used to save money (note: if trip cost is the same for both vehicles, say something appropriate). The function's parameters are:
distanceMiles: the trip's distance in miles (type: float)
veh1Name: a string representing the first vehicle (e.g. "Tesla")
veh1SpeedMPH: vehicle 1's speed in miles per hour (type: float)
veh1MPG: vehicle 1's fuel efficiency in miles per gallon (type: float)
veh2Name: a string representing the second vehicle (e.g. "BYD")
veh2SpeedMPH: vehicle 2's speed in miles per hour (type: float)
veh2MPG: vehicle 2's fuel efficiency in miles per gallon (type: float)
gasCostPerGallon: the price of one gallon of gas in dollars (type: float)
hotelCostPerNight: cost of one night in a hotel in dollars (type: float)
breakfastCostPerDay: cost of a day's breakfast in dollars (type: float)
lunchCostPerDay: cost of a day's lunch in dollars (type: float)
dinnerCostPerDay: cost of a day's dinner in dollars (type: float)
ChooseVehicleForTrip must use/call tripCost, the function you write for Q1. Note that you will need to convert units. Look up and use good accurate conversion factors for miles/kilometers and gallons/liters. Note: Your function should not return anything. Instead it should print information about the cost of the trip for both vehicle 1 and vehicle 2 and should recommend choosing the vehicle that yields the less expensive trip. For example,
>>> chooseVehicleForTrip(1000.0, "Bugatti", 100.0, 1.0, "Vespa", 27.0, 100.0, 2.10, 55.0, 6.50, 11.0, 23.0) 1000.0 miles in vehicle 'Bugatti' will cost $2195.50, including 1 hotel nights and $40.50 food cost 1000.0 miles in vehicle 'Vespa' will cost $414.00, including 4 hotel nights and $173.00 food cost. To save money, use 'Vespa' >>>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started