data_structures.stacks.prefix_evaluation ======================================== .. py:module:: data_structures.stacks.prefix_evaluation .. autoapi-nested-parse:: Python3 program to evaluate a prefix expression. Attributes ---------- .. autoapisummary:: data_structures.stacks.prefix_evaluation.calc data_structures.stacks.prefix_evaluation.test_expression Functions --------- .. autoapisummary:: data_structures.stacks.prefix_evaluation.evaluate data_structures.stacks.prefix_evaluation.is_operand Module Contents --------------- .. py:function:: evaluate(expression) Evaluate a given expression in prefix notation. Asserts that the given expression is valid. >>> evaluate("+ 9 * 2 6") 21 >>> evaluate("/ * 10 2 + 4 1 ") 4.0 .. py:function:: is_operand(c) Return True if the given char c is an operand, e.g. it is a number >>> is_operand("1") True >>> is_operand("+") False .. py:data:: calc .. py:data:: test_expression :value: '+ 9 * 2 6'