Question: why an i getting this error and also not getting the value for miles per gallon, total gas cost, cost per mile Exercise 2-1 Modify

 why an i getting this error and also not getting the
value for miles per gallon, total gas cost, cost per mile Exercise
why an i getting this error and also not getting the value for miles per gallon, total gas cost, cost per mile 2-1 Modify the Miles Per Gallon program In this exercise, you'll test

Exercise 2-1 Modify the Miles Per Gallon program In this exercise, you'll test and modify the code for the Miles Per Gallon program in figure 2-15. When you're finished, the program will get another user entry and do two more calculations, so the console will look something like this: Enter miles driven: 150 Enter gallons of gas used: 15 Enter cost per gallon: Miles Per Gallon: 10.0 Total Gas Cost: Cost Per Milor 45.0 0.3 If you have any problems when you test your changes, please refer to figure 1.9 of the last chapter, which shows how to fix syntax and runtime errors. 1. Start IDLE and open the mpg.py file that should be in this folder: python/exercises/ch02 2. Press F5 to compile and run the program. Then, enter valid values for miles driven and gallons used. This should display the miles per gallon in the interactive shell. 3. Test the program with invalid entries like spaces or letters. This should cause the program to crash and display error messages for the exceptions that occur. 4. Modify this program so the result is rounded to just one decimal place. Then, test this change. 5. Modify this program so the argument of the round function is the arithmetic expression in the previous statement. Then, test this change. 6. Modify this program so it gets the cost of a gallon of gas as an entry from the user. Then, calculate the total gas cost and the cost per mile, and display the results on the console as shown above. Systems rectangle A pg62EX2=1.py - C:\Users\antuc OneDrive\Documents\Phython Programming\pg62Ex2-1.py ( File Edit Format Run Options Window Help # display a title print("The Miles per gallon program") print #get input from the user miles_driven= float (input ("Enter miles driven:\t\t")) gallons_gas_used= float (input("Enter gallons of gas used: \t")) cost_per_gallon= float (input("Enter cost per gallon:\t\t")) #calculate and round miles per gallon Mile_per_gallon= round (miles_driven/gallons_gas_used, 1) total_gas_cost= round (gallons_gas_used* cost_per_gallon, 1) Cost_per_mile=round (total_gas_cost/miles_driven, 1) #display the results print) print("miles Per Gallon:10",miles_per_gallon) print("Total Gas Cost: 45\t", total_gas cost) print("Cost Per Mile:3\t", cost_per_mile IDLE Shell 29.1 File Edit Shell Debug Options Window Help Python 3.9.1 (tags/v3.9.1: 1e5d330. Dec 7 2020, 17:08:21) (MSC v.1927 64 bit (AM D64)1 on win32 Type "help","copyright", "credits" or "license for more information. >>> RESTART: C:\Users\antuc\OneDrive\Documents\Phython Programming\pg625x2-1.py The Miles per gallon program Enter miles driven 150 Enter gallons of gas used: 15 Enter cost per gallons 3 Traceback (most recent call last) Relationes veocuments Phython Programming 616X2-1. py", lin 13. In modul mpound (livenollonused Mamettront calon used to defined >>>| I In 14 C4

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!