Codecademy Logo

Learn to Code with Blockly: Variables

Variable Declaration

In programming, variables are declared by giving it a name and setting it to a value using an equals sign (‘=’). Variables can later be reassigned to other values.

dogBreed = 'corgi'

Variable Definition

In programming, variables are used to assign a name to a piece of data and to use that name to reference the data elsewhere in the program.

myName = 'Zoe'

Data Type Definition

In programming, data types are how computers classify different forms of information. They include numeric, string and boolean types.

For example, if using number data type, the program will know that arithmetic can be performed on it, but it can’t be capitalized.

Booleans Definition

In programming, booleans are a common data type. They represent the logical ideas of true and false.

String Definition

In programming, strings are a common data type. They are any sequence of characters (letters, spaces, numbers, or symbols) surrounded by single or double quotes. Strings are commonly used to represent text, speech, symbols, and other non-numerical characters.

"Hello world"
"Great work!"

Numbers definition

In programming, numbers are a common data type. They represent numerical values and can include numbers with and without decimal points.

-25
0
.68888
7039

Learn more on Codecademy