Question: Write a function compute_cost, which takes as parameters a car's fuel efficiency in miles/gallon (mpg) and gas cost in dollars/gallon and the distance of the

 Write a function compute_cost, which takes as parameters a car's fuelefficiency in miles/gallon (mpg) and gas cost in dollars/gallon and the distance

Write a function compute_cost, which takes as parameters a car's fuel efficiency in miles/gallon (mpg) and gas cost in dollars/gallon and the distance of the trip in miles, and returns the total gas cost for this trip. Write a program that begins by printing We are going on a road trip! Then, create the following variables that you read-in as input: start_place end_place distance mpg cost Write a program that outputs the following information: We are going on a road trip! The distance from A to B is x miles. The car's fuel efficiency is Y miles/gallon. The gas cost is z dollars. The trip will cost us $... replacing the letters with the values stored in variables, and ellipses (...) with the result of your function's computation. For example, if the variables are defined as follows: For example, if the variables are defined as follows: start_place = "Freebirds" end_place = "Lake Los Carneros" distance = 2.7 mpg = 20 # miles per gallon of my car cost = 3.75 The output is supposed to be We are going on a road trip! The distance from Freebirds to Lake Los Carneros is 2.7 miles. The car's fuel efficiency is 20.0 miles/gallon. The gas cost is 3.75 dollars. The trip will cost us $0.51 How did we determine this? Well, if you drive at 20 miles/gallon (mpg) and the cost of gas (dollars/gallon), you can compute how much it would cost you to drive the distance by using (miles * (gallon/miles) * (dollars/gallon) -> dollars)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!