*This project may need some explanation
by an instructor*

A numerical expression is a mathematical statement that involves numbers and operation symbols.

Infix expressions are characterized by the placement of operators between operands. (e.g. 6 + 3)

Postfix expressions are characterized by placement of operators after the operands. (e.g. 6 3 +)

Reverse Polish notation (RPN) is postfix notation.

The description "Polish" refers to the nationality of logician Jan Ćukasiewicz, who invented Polish notation in 1924.

For example:

Infix Expression | Results | Reverse Polish Notation Expression | Notes |
---|---|---|---|

5 + 2 + 8 | 15 | 5 2 + 8 + | same operator precedence |

5 + 2 * 8 | 21 | 5 2 + 8 * | different operator precedences |

(5 + 2) * 8 | 56 | 5 2 + 8 * | sub-expression |

2 ** 4 + 5 | 21 | 2 4 ** 5 + | mult-character (**) operator |

(10 / 2) * 3 | 15 | 10 2 / 3 * | sub-expression |

((2 * 3) - (4 - 8 * 2)) | 18 | 2 3 * 4 8 2 * - - | sub-expression |

((2 * 3) - (4 * 8 - 2)) | -24 | 2 3 * 4 8 * 2 - - | sub-expression |

2**3 - 4 * 2 | 0 | 2 3 ** 4 2 * - | mult-character (**) operator |

For hints, code examples, etc. click HERE .

What is the difference between the Python "collections.deque" and "Queue" modules?

Using the Python "collections.deque" module, create a stack class (LIFO queue). Implement the following methods:

- pop from TOS (element removed from stack)
- push onto TOS (element added to stack)
- modify TOS
- is stack empty
- return TOS (element not removed from stack)
- length of stack
- clear (empty) a stack

Create an interactive program to demonstrate the stack methods.

Are there any other methods that are needed?

Using the Python "collections.deque" module, create a queue class (FIFO queue). Implement the following methods:

- pop from FOQ (element removed from queue)
- push onto BOQ (element added to queue)
- modify FOQ
- is queue empty
- return FOQ (element not removed from queue)
- length of queue
- clear (empty) a queue

Create an interactive program to demonstrate the queue methods.

Are there any other methods that are needed?

Create an interactive program to tokenize an infix numerical expression.

- ask the user to enter an infix numeric expression
- parse the infix expression into tokens (operators and operands)
- display the tokens

Define "syntax" and "semantics" as it relates to computer programming languages.

Create an interactive program to convert an infix numeric expressions

to a Reverse Polish Notation (RPN) numeric expressions.

- ask the user to enter an infix numeric expression (string)
- parses the infix expression into tokens (strings)
- using the tokens, create a Reverse Polish Notation
numeric expression (string)

(a single string with tokens separated by a space) - display the results
- loop

Code the algorithm found HERE .

Expand the project

- convert to a GUI
- add scientific notation

Infix notation (Wikipedia)

Reverse Polish notation (Wikipedia)

Shunting yard algorithm (Wikipedia)

Infix, Postfix and Prefix Expressions/Notations

Converting infix to RPN (shunting-yard algorithm)

Rules to Convert Infix to Postfix (Reverse Polish) Expression using a Stack (YouTube)

How to convert Infix expressions to Reverse Polish Notation expressions (Youtube)