Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

# 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

Students also viewed these Databases questions

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago

Question

8. How would you explain your decisions to the city council?

Answered: 1 week ago