2.14 LAB: Driving costs Driving is expensive. Write a program with a car's gas mileage (miles/gallon) and the cost of gas (dollars/gallon) as floating point input, and output the gas cost for 20 mles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point which can be achieved as fo lows: print (f'(your_value1:.2f) (your_value2:.2f) (your_value3:.2f}') Ex If the input is: 25.0 3.1599 where the cas mileage is 25.0 miles/gallon and the cost of gas is $3.1599/gallon, the output is: 2.53 9.48 63.20 Note: Real per-mile cost would also include maintenance and depreciation. 4708825680276day?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Don't send me wrong and plagiarised response. I'm getting error. Please resolve my issue but don't copy from others. I'll report otherwise.
**2.14 LAB: Driving Costs**

Driving is expensive. Write a program with a car’s gas mileage (miles/gallon) and the cost of gas (dollars/gallon) as floating-point input, and output the gas cost for 20 miles, 75 miles, and 500 miles.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
```python
print(f'{your_value1:.2f} {your_value2:.2f} {your_value3:.2f}')
```

**Example**

If the input is:
```
25.0
3.1599
```

Where the gas mileage is 25.0 miles/gallon and the cost of gas is $3.1599/gallon, the output is:
```
2.53  9.48  63.20
```

*Note: Real per-mile cost would also include maintenance and depreciation.*

---

**Programming Exercise**

Below the instructions, there is a code snippet in the Python language designed to calculate the driving costs. It requires input for miles per gallon and dollars per gallon, then computes and prints the cost for driving 20, 75, and 500 miles.

**Code Explanation**

The code contains:
- Two floating-point inputs for miles per gallon and dollars per gallon.
- Calculation of dollars per mile by dividing dollars per gallon by miles per gallon.
- Computing the cost for driving 20, 75, and 500 miles.
- Output these costs with two decimal precision.

**Code:**
```python
miles_per_gallon = float(input())
dollars_per_gallon = float(input())

dollars_per_mile = dollars_per_gallon / miles_per_gallon

miles_20 = 20 * dollars_per_mile
miles_75 = 75 * dollars_per_mile
miles_500 = 500 * dollars_per_mile

print(f'{miles_20:.2f} {miles_75:.2f} {miles_500:.2f}')
```

**Error Handling**

In this example, an error occurs because a variable name is entered incorrectly (`miles_20` is incorrectly typed as `mules_20`). Correcting this typo resolves the issue.

**User Interface**

- A field is available to input the values, which can then be used by pressing the "Run program" button to calculate the
Transcribed Image Text:**2.14 LAB: Driving Costs** Driving is expensive. Write a program with a car’s gas mileage (miles/gallon) and the cost of gas (dollars/gallon) as floating-point input, and output the gas cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: ```python print(f'{your_value1:.2f} {your_value2:.2f} {your_value3:.2f}') ``` **Example** If the input is: ``` 25.0 3.1599 ``` Where the gas mileage is 25.0 miles/gallon and the cost of gas is $3.1599/gallon, the output is: ``` 2.53 9.48 63.20 ``` *Note: Real per-mile cost would also include maintenance and depreciation.* --- **Programming Exercise** Below the instructions, there is a code snippet in the Python language designed to calculate the driving costs. It requires input for miles per gallon and dollars per gallon, then computes and prints the cost for driving 20, 75, and 500 miles. **Code Explanation** The code contains: - Two floating-point inputs for miles per gallon and dollars per gallon. - Calculation of dollars per mile by dividing dollars per gallon by miles per gallon. - Computing the cost for driving 20, 75, and 500 miles. - Output these costs with two decimal precision. **Code:** ```python miles_per_gallon = float(input()) dollars_per_gallon = float(input()) dollars_per_mile = dollars_per_gallon / miles_per_gallon miles_20 = 20 * dollars_per_mile miles_75 = 75 * dollars_per_mile miles_500 = 500 * dollars_per_mile print(f'{miles_20:.2f} {miles_75:.2f} {miles_500:.2f}') ``` **Error Handling** In this example, an error occurs because a variable name is entered incorrectly (`miles_20` is incorrectly typed as `mules_20`). Correcting this typo resolves the issue. **User Interface** - A field is available to input the values, which can then be used by pressing the "Run program" button to calculate the
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education