Variables Flashcards

1
Q

What is a variable?

A

A variable is a named memory location that stores the data you enter into it.

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

How many values can a variable store? What happens to a previous value when a new value gets stored?

A

A variable can only store one value at a time. When a new value is stored in a variable, the previous value gets overwritten.

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

What is the assignment operator?

A

Values are assigned to variables using the assignment operator(=). For example, statement x=15 assigns the value 15 to the variable x

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

What are the rules for entering a variable name?

A

*It must start with a letter(capital or small) or an underscore(_)
*A variable name must consist of only a letter, digit, or underscore, and no other character is allowed.
*A Python keyword cannot be used as a variable name. Ex.else

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

What are some things to note in variable names?

A

*Variable names can be of any length
*Variable names are case sensitive(eg. Age and age are different variable names)
*A space is not allowed in a variable name

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

What happens if a variable names whose value is not assigned is being used?

A

If a variable name is being used without assigning a value(it is undefined), then it is an error

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