Chapter 6 Flashcards

1
Q

what is a variable? can it be changed and what should you remember if you change it?

A

A variable is a placeholder. You can stick a number like 5.95 into a variable. After you’ve placed a number in the variable, you can change your mind and put a different number, like 30.95, into the variable. (That’s what varies in a variable.) Of course, when you put a new number in a variable, the old number is no longer there. If you didn’t save the old number somewhere else, the old number is gone.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is stored in a variable? what can you do with what is stored in a variable? is what is stored always a number? are there different types of data that can be stored in a variable?

A

The thing stored in a variable is called a value. A variable’s value can change during the run of a program (when SnitSoft adds the shipping and handling cost, for example). The value stored in a variable isn’t necessarily a number. (You can, for example, create a variable that always stores a letter.) The kind of value stored in a variable is a variable’s type. (You can read more about types in the rest of this chapter and in the next two chapters.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how does a variable name and a variable itself differ or relate?

A

There’s a subtle, almost unnoticeable difference between a variable and a variable’s name. Even in formal writing, I often use the word variable when I mean variable name. Strictly speaking, amount is the variable name, and all the memory storage associated with amount (including the value and type of amount) is the variable itself. If you think this distinction between variable and variable name is too subtle for you to worry about, join the club

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what else can you call a variable as it relates to it’s name?

A

Every variable name is an identifier — a name that you can make up in your own code (for more about this topic, see Chapter 4).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly