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 : In some countries, a vehicle's fuel efficiency is measured in miles per gallon. In other countries, the efficiency is measured in litres per For example, miles per Imperial gallon is equivalent to approximately litres per
You are going to write Python statements that convert miles per gallon to litres per One Imperial gallon is equal to approximately litres. One mile is equal to approximately
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 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 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 which represents miles per gallon
The second statement creates a new vartable named LITRESPERGALLON and assigns it the value 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 KMSPERMILE and assigns it the value
The fourth statement converts the mileage referred to by mpg to the equivalent fuel consumption, measure in litres per using the formula you derived earlier. This value should be assigned to a variable named fuelconsumption.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
