Expression Evaluator¶
Run the Expression Evaluator MicroSim Fullscreen
Edit in the p5.js Editor
About This MicroSim¶
Order of operations is usually taught as a table to memorize. This MicroSim
lets students watch it happen: each Next Step highlights the operation
Python computes next and collapses it into its value, while a precedence
ladder shows which rank ("running now") is active. Presets cover the classic
2 + 3 * 4 surprise, parentheses, left-to-right evaluation, exponents, and
the // / % pair.
Learning objective: The student will be able to evaluate an arithmetic expression in the same order Python does, one operation at a time.
- Bloom's Taxonomy (2001): Understand → Apply — interpret, execute, predict
- Interaction pattern: step-through reduction with a live precedence legend
How to Use¶
- Pick an expression and predict the final answer before stepping.
- Click Next Step. The amber highlight shows the operation Python runs next; the ladder shows why it was chosen.
- Compare
2 + 3 * 4with(2 + 3) * 4— same numbers, different answers. - Try
10 - 4 - 3to see that equal-rank operators run left to right.
Iframe Embed Code¶
You can add this MicroSim to any web page by adding this to your HTML:
1 2 3 4 | |
Lesson Plan¶
Grade Level¶
Upper elementary and middle school (ages 10-14), Chapter 6 (Math and Arithmetic)
Duration¶
10 minutes
Prerequisites¶
- The seven arithmetic operators, including
**,//, and%(Chapter 6)
Activities¶
- Predict (3 min): Students write down answers for all five preset expressions before using the sim.
- Step and check (5 min): Step through each expression. Score their predictions.
- Discuss (2 min): "Which prediction surprised you most, and what rule explains it?"
Assessment¶
- Student correctly evaluates a new mixed expression like
1 + 2 ** 2 * 3by hand - Student can explain why
10 - 4 - 3is 3 and not 9 - Student can state when parentheses change a result and when they do not
References¶
- Python Documentation — Operator precedence — the full precedence table
- p5.js — the JavaScript library used to build this MicroSim