Python 3
Posted: Tue Jul 05, 2022 10:27 am
Python 3
2. Ask the user for the speed in miles per hour, hours traveled (should be an integer), miles per gallon your vehicle gets, and price of gas per gallon. 3. Using a while loop, output for each hour the distance traveled, gallons of gas used, and cost so far (see example below). 4. Your output should be in the format of the example, with two decimal places, spacing, etc. (User input in red). You may need to use multiple back-to-back tabs in your output to get the correct alignment. 5. You can use any method of formatting you want, as long as it matches the example. Speed in miles per hour: 40 Hours traveled: 3 Miles per gallon: 23 Price of gas per gallon: 2.19 Gallons Hour 1 2 3 Distance 40 80 120 1.74 3.48 5.22 Cost $3.81 $7.62 $11.43
2. Ask the user for the speed in miles per hour, hours traveled (should be an integer), miles per gallon your vehicle gets, and price of gas per gallon. 3. Using a while loop, output for each hour the distance traveled, gallons of gas used, and cost so far (see example below). 4. Your output should be in the format of the example, with two decimal places, spacing, etc. (User input in red). You may need to use multiple back-to-back tabs in your output to get the correct alignment. 5. You can use any method of formatting you want, as long as it matches the example. Speed in miles per hour: 40 Hours traveled: 3 Miles per gallon: 23 Price of gas per gallon: 2.19 Gallons Hour 1 2 3 Distance 40 80 120 1.74 3.48 5.22 Cost $3.81 $7.62 $11.43