Question: Exercise 2 : In some countries, a vehicle's fuel efficiency is measured in miles per gallon. In other countries, the efficiency is measured in litres

Exercise 2: In some countries, a vehicle's fuel efficiency is measured in miles per gallon. In other countries, the efficiency is measured in litres per 100km. For example, 32 miles per Imperial gallon is equivalent to approximately 8.83 litres per 100km.
You are going to write Python statements that convert miles per gallon to litres per 100km. One Imperial gallon is equal to approximately 4.54609 litres. One mile is equal to approximately 1.60934km.
Hint: we recommend that, before you write any Python code, treat this as a math problem and derive a formula for converting miles per gallon to litres per 100km, using the conversion factors listed in the previous paragraph. Verify that the units in the conversion factors cancel out properly.
In PyTutor, click Edit this code. The memory model from Exercise 1 will disappear. Delete the code in PyTutor's editor, then type four assignment statements:
The first statement creates a new variable named mpg and assigns it the value 32(which represents 32 miles per gallon).
The second statement creates a new vartable named LITRES_PER_GALLON and assigns it the value 4.54609.(Note that the names of Python variables that have values that are supposed to remain constant are, by convention, usually written entirely in uppercase.)
The third statement creates a new variable named KMS_PER_MILE and assigns it the value 1.60934.
The fourth statement converts the mileage referred to by mpg to the equivalent fuel consumption, measure in litres per 100km, using the formula you derived earlier. This value should be assigned to a variable named fuel_consumption.
 Exercise 2: In some countries, a vehicle's fuel efficiency is measured

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!