Question: In computer programming there are three kinds of errors: syntax errors, runtime errors, and logic errors. The code fragment below is meant to calculate a
In computer programming there are three kinds of errors: syntax errors, runtime errors, and
logic errors. The code fragment below is meant to calculate a cars fuel economy after reading
in the distance travelled and amount of petrol used. The fuel economy is calculated by the
following formula: kmPerLitre kilometers litres. The code fragment contains syntax, logic
and potential runtime errors. Identify and correct at least five errors in the
def efficiencydist gas
return distgas
km input How far did your car travel? In kilometers?
liters input How much gas did you use? In liters
MPG efficiencydisttraveled, Liters
print MPG
Please note that the line numbers are not part of the code. Assuming that users will only
provide valid inputs, find at least three syntax errors, one runtime error, and one logical error
in the above code.
For each of these errors, state the number of the line on which it occurs and how it should be
corrected.
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
