Math for Computer Science

1 | Variables

Table of Contents Next Lesson

Examples
Practice Problems

Introduction

What are variables?

  • A variable represents a quantity that can change.
  • A constant is a quantity that cannot change.
  • Any symbol can be used as a variable.
  • In computer science, variable quantities are often represented by words or abbreviations to help programmers understand the code.
  • In mathematics, it is customary represent a variable quantity with a letter of the alphabet, like x or y.

Examples

Addition and subtraction

Q: Find the value of the variable:
9 + x = 12

A: Since 9 + 3 = 12, the value of x must be 3.


Multiplication and division

Q: Find the value of the variable:
4 × b = 20

A: Since 4 × 5 = 20, the value of b must be 5.

Practice | Variables

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