Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please implement expression evaluator (similar to your calculator) using Python. The input text files *.dat should be at the same directory with your .py file.

Please implement expression evaluator (similar to your calculator) using Python. The input text files *.dat should be at the same directory with your .py file. Each input file has only one expression consists of positive integers, whitespaces like space (' ') or tab, add ('+'), multiply ('*'), open parenthesis ('('), and close parenthesis (')'). If input contains any other characters or imbalanced open and close parenthesis, your .py should report error and handle the next input file if there is one. The parenthesis has the highest precedence, the * is second highest, and + is the lowest. Since you read input as a character string, you need to convert numbers to integer by int(). If the input is a legal expression, your .py should output correct answer for the expression.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions