Skip to main content

Lesson 1.3: Math and Text Expressions

An expression is code that produces a value. A number block is a small expression. A math block is a larger expression because it reads input values, performs an operation, and produces a result.

Expressions can fit inside other blocks. In set total to 4 + 3, the addition runs first and produces 7. The assignment then stores that result in total.

Math expressions use operations such as add, subtract, multiply, and divide. Text expressions can join values. Joining Team and 12 produces the text Team 12. It does not perform number addition.

Nested expressions are read from the inside out. In (2 + 3) * 4, the inner addition produces 5, then multiplication produces 20.

Guided practice

Create a variable named total. Store the result of (6 + 2) * 3, then print total. Use Step to confirm when the expression is evaluated and when its result is assigned.

Next, join the text Total: with the variable value and print the result. Keep the number in total; only the output needs joined text.

Loading the block workspace...

Ready to move on?

Only mark complete if you genuinely understand the material. Your progress will be saved in this browser.

Stuck on this lesson?

Ask about anything on this page. It can see which lesson you have open and which part you are reading.