Math for Computer Science

8 | Variable expressions

Back to Table of Contents
Previous Lesson Table of Contents

Examples
Practice Problems

Introduction

How are variable expressions evaluated?

  • To evaluate a variable expression, we first substitute a value for the variable, then apply the order of operations.
  • Since we can substitute any value for a variable, variable expressions can be used to predict an outcome for a given condition.

Examples

Evaluating variable expressions (one-step)

Q: Evaluate for z = 5:
z + 9

A: First, we substitute for z. Then, we add:
z + 9 = 5 + 9 = 14


Evaluating variable expressions (two-step)

Q: Evaluate for c = 3:
4 × c − 5

A: First, we substitute for c. Then, we apply the order of operations:
4 × c − 5 = 4 × 3 − 5 = 12 − 5 = 7

Practice | Variable Expressions

Click "Create Report" upon completion of any practice set to document your progress: Example