#66MediumFunctions· State and Program Design
Calculator Engine for a Tkinter GUI
Input format
`keys`: a list of single-character strings.
Output format
A list of display strings, one after each key.
Examples
Input: keys = ["1","2","+","3","*","2","="]
Output: ["1","12","12","3","15","2","30"]
`12 + 3` is calculated when `*` is pressed (15), then `15 * 2 = 30`.
Input: keys = ["7","/","0","=","5"]
Output: ["7","7","0","Error","5"]
Division by zero shows Error; the next digit starts a fresh number.
Constraints
- 0 <= len(keys) <= 1000
- Results stay below 10^12 in absolute value
Study first
- #python
- #state-machine
- #gui
- #tkinter
- #calculator
