Question: python Polish notation (also called prefix notation) is a notation for mathematical expressions in which operators come before their operands. For example, using Polish notation,
Polish notation (also called prefix notation) is a notation for mathematical expressions in which operators come before their operands. For example, using Polish notation, the algebraic expression (5. 4. 3) / 2 would be written as / . * 5 4 3 2. Write a function evaluate_polish_notation which takes as input a string expr giving an expression in Polish notation and returns its value as a floating point number. Your function should support the binary operators + (addition). (subtraction). * (multiplication), and / (division). (You can assume that your function is only called with valid input so you do not need to write code to deal with erroneous input here.) Hint. Have a look at the function evaluate_rpn from Lecture 2. Can you do something similar by processing an expression from the right (rather than the left)? Be careful with the order of operands: - 23 should evaluate to -1. not to 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
