Question
Use Python (python 3.6.2) to create a simple calculator that accepts Reverse Polish Notation (RPN) and displays the final answer (Intermediate steps or results need
Use Python (python 3.6.2) to create a simple calculator that accepts Reverse Polish Notation (RPN) and displays the final answer (Intermediate steps or results need not be displayed). It only accepts 4 operators +, -, *, /. You should convert the algebraic notation to RPN before using it as input to your program. The input will be provided in a text file called input_RPN.txt. There will be one RPN expression in each line. Your code should be able to read in the file and print the result for each RPN in a new line. Example of RPN: - If you want to compute the answer for the algebraic notation 4 + 2 , your RPN will be 4 2 + and your output should be 6. This is a simple expression. More complex algebraic notations will be used to test your program like the one below. Example algebraic notation: ( 4 + 2 * 5 ) / ( 1 + 3 * 2 ) Translated into RPN: 4 2 5 * + 1 3 2 * + /
Your code will take in an algebraic expression and convert it to RPN and evaluate the RPN. Print the RPN and the result in separate lines
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