Variables, Types, and Simple Expressions
Storing information in programs
Variables
A variable is a named place for storing a value in a program. It lets a program remember information and use it later.
Types
A type tells us what kind of data a value is. Common beginner types include numbers, text, and booleans. A boolean has only two values: true or false.
Examples of variables
A variable named age might store , while a variable named isLoggedIn might store true.
What is a variable used for?
Variables let programs store and refer to information.
Correct answer: Storing a value with a name
What is a boolean value?
Booleans are used for yes/no or on/off decisions.
Correct answer: A value that is either true or false
Expressions
An expression combines values and operators to produce a new value. For example, is an expression whose value is .
What is the value of ?
Adding and gives .
Correct answer: 7
Name one common data type and what it stores.
Other valid answers include number, integer, or boolean with an explanation.
Correct answer: String stores text