What Are Variables and Data Types?

Variables

A variable is simply a name to which a value can be assigned. Under the hoods, a variable is a named memory location that holds data during program execution. Think of it as a labeled container that we can use to store and manage information throughout our code.

Programmers use symbolic names to describe a specific type of information in the solution being coded. For example, if we want to calculate the area of a rectangle, the rectangle’s length is one piece of information, and the width is the second piece of required information. Inside the code, these two values would be treated as variables.

The simplest way to assign a value to a variable is through the = operator.

Get hands-on with 1200+ tech skills courses.