Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 37 · Getting Started

Variables and Expressions

Learn what a variable is, how algebraic expressions are built, and how to evaluate them by substituting numbers, with worked examples and a runnable checker.

Algebra is arithmetic with a twist: some numbers are not known yet, or they can change. Instead of writing a number, we write a letter that stands in for it. That letter is called a variable. Once you are comfortable with variables, you can describe patterns, write rules that work for every number, and solve problems that arithmetic alone cannot.

In this lesson you will learn the vocabulary of algebra (variable, constant, coefficient, term, expression) and how to evaluate an expression, which means finding its value when each variable is replaced by a number.

Variables and constants

A variable is a symbol, usually a letter such as x, n or t, that represents a number that can vary or is not yet known. A constant is a number that never changes, such as 7 or -2.5.

Suppose a taxi charges a fixed fee of 3 dollars plus 2 dollars for each kilometer. The distance changes from trip to trip, so call it d. The cost in dollars is:

Text
3 + 2d

Here 2d means 2 × d. In algebra we leave out the multiplication sign between a number and a letter, because × looks too much like the letter x.

Parts of an expression

An algebraic expression is a combination of numbers, variables and operations (add, subtract, multiply, divide, powers). It has no equals sign. Examples: 5x, 3 + 2d, a² - 4b + 9.

Expressions are built from terms. A term is a number, a variable, or a product of numbers and variables. Terms are separated by + or - signs.

Piece What it is In 4x² - 7x + 9
Term One part separated by + or - 4x², -7x, 9
Coefficient The number multiplying a variable 4 and -7
Constant term A term with no variable 9
Exponent How many times the base is multiplied the 2 in x²

Notice that the sign belongs to the term that follows it. The second term is -7x, not 7x.

A variable on its own, like x, has an invisible coefficient of 1. So x means 1x, and -x means -1x.

Evaluating an expression

To evaluate an expression, substitute (replace) each variable with its given number, then calculate using the order of operations (you will study this in the next lesson).

Example 1. Evaluate 3 + 2d when d = 5.

Replace d with 5: 3 + 2(5) = 3 + 10 = 13. A 5 km trip costs 13 dollars.

Example 2. Evaluate 4x² - 7x + 9 when x = 3.

4(3)² - 7(3) + 9 = 4(9) - 21 + 9 = 36 - 21 + 9 = 24.

Example 3. Evaluate x² when x = -4. Use brackets around negative numbers: (-4)² = 16. Without brackets, -4² would mean "the negative of 4²", which is -16. Brackets matter.

Use parentheses whenever you substitute a number, especially a negative one. It prevents sign mistakes.

Python Evaluate an expression for several values

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

In the code, ** means "to the power of", and the variable d or x is a function input. A function is a rule that turns an input into an output. You will meet them properly later in this course.

Why variables are useful

A formula is an expression that holds for every value of its variables. The perimeter of a rectangle with length l and width w is 2l + 2w. Plug in l = 8 and w = 3 and you get 2(8) + 2(3) = 22. Plug in different numbers and the same formula still works.

Python One formula, many rectangles

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Common mistakes

  1. Forgetting that 2x means multiplication. If x = 5, then 2x = 10, not 25.
  2. Dropping brackets with negatives. Evaluate x² at x = -3 as (-3)² = 9.
  3. Treating x² as 2x. x² means x × x. When x = 4, x² = 16 but 2x = 8.
  4. Mixing up terms. In 5 - 2x, the second term is -2x, so its coefficient is -2.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What is the coefficient of x in the term -6x?

    The coefficient is the number multiplying the variable, and the sign belongs to it, so it is -6.
  2. 2. Evaluate 5 + 3n when n = 4.

    3(4) = 12, then 5 + 12 = 17. The number 3 multiplies n; it is not added to 5 first.
  3. 3. Evaluate x² when x = -5.

    (-5)² = (-5)(-5) = 25. A negative times a negative is positive.
  4. 4. How many terms does 2a - 7b + 4 have?

    The terms are 2a, -7b and 4, separated by the plus and minus signs.

Summary

  • A variable is a letter standing for a number that can change or is unknown; a constant never changes.
  • An expression is made of terms; the coefficient is the number multiplying a variable.
  • 2x means 2 × x, and x² means x × x.
  • To evaluate, substitute numbers in brackets, then calculate.
  • A formula such as 2l + 2w works for every choice of the variables.

Next: Order of Operations in Algebra