Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Write function : gasCostPerLiter) efficiency of a vehicle # The inputs are all floats: printTimeAndCostofTrip (distanceInKM, speedInKPH, KmPerLiter, that computes the time and cost
# Write function : gasCostPerLiter) efficiency of a vehicle # The inputs are all floats: printTimeAndCostofTrip (distanceInKM, speedInKPH, KmPerLiter, that computes the time and cost of a trip based on speed and fuel - distanceInKilometers: the trip distance in kilometers speedInKPH: the speed of the trip in kilometers per hour KmPerLiter: the number of kilometers traveled on one liter of gas gasCostPerLiter: the cost in of one liter of gas in dollars # The function should print two things: time required for trip and gas cost for trip. # Note: The calculations in this functi n are closely related t some of the calculations needed in HW1! # Pseudocode/outline: # def printTimeAndCostOfTrip (distance InKilometers, speedinKPH, KmPerLiter, gasCostPerLiter): # 1 . calculate time required in h urs (from distance and speed), # 2" calculate liters of gas needed (from distance and kpl), # 3. calculate total cost of gas (from gas cost per liter and associating result with a variable associating result with a different variable liters needed) again saving result in a variable # 4. print two messages, using values saved from the above calculations # Example usage: # >>> printTimeAndCostOfTrip (100.0, 20.0, 16.0, 2.25) Time needed for trip: 5.0 hours. # Gas cost for the trip: $14.0625
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