Python 4.3.1.10 LAB: Converting fuel consumption
4.3.1.10 LAB |
Objectives
- improving the student's skills in defining, using and testing functions.
Scenario
A car's fuel consumption may be expressed in many different ways. For example, in Europe, it is shown as the amount of fuel consumed per 100 kilometers.
In the USA, it is shown as the number of miles traveled by a car using one gallon of fuel.
Your task is to write a pair of functions converting l/100km into mpg "mile per gallon", and vice versa.
Sandbox |
are named liters_100km_to_miles_gallon and miles_gallon_to_liters_100km respectively;
take one argument (the value corresponding to their names)
Complete the code in the editor.
Run your code and check whether your output is the same as ours.
Here is some information to help you:
1 American mile = 1609.344 metres; 1 mile = "1.60934" meters
1 American gallon = 3.785411784 litres.
Expected output
- 60.31143162393162
- 31.36194444444444
- 23.52145833333333
- 3.9007393587617467
- 7.490910297239916
- 10.009131205673757
Solution Code:
=================================================================================
0 Comments
Your opinion matters, your voice makes us proud and happy. Your words are our motivation.