USE PYTHON Python already supports math, whereby you can write code to add, subtract, multiply, or divide values and even variables. But let’s write a program that enables users to do math, even without knowing Python. In a file called interpreter.py, implement a program that prompts the user for an arithmetic expression and then calculates and outputs the result as a floating-point value formatted to one decimal place. Assume that the user’s input will be formatted as x y z, with one space between x and y and one space between y and z, wherein: x is an integer y is +, -, *, or / z is an integer For instance, if the user inputs 1 + 1, your program should output 2.0. Assume that, if y is /, then z will not be 0. Note that, just as python itself is an interpreter for Python, so will your interpreter.py be an interpreter for math! Please see 2 attached photos for demo and Test program. **USE PYTHON** THANKS
USE PYTHON
Python already supports math, whereby you can write code to add, subtract, multiply, or divide values and even variables. But let’s write a program that enables users to do math, even without knowing Python.
In a file called interpreter.py, implement a program that prompts the user for an arithmetic expression and then calculates and outputs the result as a floating-point value formatted to one decimal place. Assume that the user’s input will be formatted as x y z, with one space between x and y and one space between y and z, wherein:
- x is an integer
- y is +, -, *, or /
- z is an integer
For instance, if the user inputs 1 + 1, your program should output 2.0. Assume that, if y is /, then z will not be 0.
Note that, just as python itself is an interpreter for Python, so will your interpreter.py be an interpreter for math!
Please see 2 attached photos for demo and Test program.
**USE PYTHON**
THANKS
![Demo
```bash
$ python interpreter.py
Expression: 1 + 1
2.0
$ python interpreter.py
Expression: 4 / 3
1.3
$ python interpreter.py
Expression: 100 - 1
99.0
```
Before You Begin](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F61433d54-b9a0-4446-a009-5d05dd47b637%2F9c072377-6705-4962-8bd6-3e0be84f13fb%2Fe96vgmk_processed.jpeg&w=3840&q=75)
![Here's how to test your code manually:
- Run your program with `python interpreter.py`. Type `1 + 1` and press Enter. Your program should output:
- `2.0`
- Run your program with `python interpreter.py`. Type `2 - 3` and press Enter. Your program should output:
- `-1.0`
- Run your program with `python interpreter.py`. Type `2 * 2` and press Enter. Your program should output:
- `4.0`
- Run your program with `python interpreter.py`. Type `50 / 5` and press Enter. Your program should output:
- `10.0`](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F61433d54-b9a0-4446-a009-5d05dd47b637%2F9c072377-6705-4962-8bd6-3e0be84f13fb%2Fybaccow_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)