Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started