Question
1. Write a Python function, tripCost(distance, vehSpeed, vehMPG, gasCostPerGallon, hotelCostPerNight) that returns the cost of a trip of based on several parameters The function's parameters
1. Write a Python function, tripCost(distance, vehSpeed, vehMPG, gasCostPerGallon, hotelCostPerNight) that returns the cost of a trip of based on several parameters The function's parameters are:
distance: the trip's distance in miles (type: float), vehSpeed: the speed of the vehicle used for the trip, in miles per hour (type: float), vehMPG: the vehicle fuel efficiency in miles per gallon (type: float), gasCostPerGallon: the price of one gallon of gas in dollars (type: float), hotelCostPerNight: the cost of one night in a hotel 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 costs) equal to hotelCostPerNight. Note: 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.
2. Write a Python function, chooseVehicleForTrip(distance, veh1Name, veh1Speed, veh1MPG, veh2Name, veh2Speed, veh2MPG, gasCostPerGallon, hotelCostPerNight) 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:
distance: the trip's distance in miles (type: float), veh1Name: a string representing the first vehicle (e.g. "Tesla") ,veh1Speed: 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. "Dongfeng"), veh2Speed: 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: the cost of one night in a hotel in dollars (type: float)
For full credit, chooseVehicleForTrip must use/call tripCost, the function you write for Q1.
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