Variables Flashcards
What is a variable?
A variable is a named memory location that stores the data you enter into it.
How many values can a variable store? What happens to a previous value when a new value gets stored?
A variable can only store one value at a time. When a new value is stored in a variable, the previous value gets overwritten.
What is the assignment operator?
Values are assigned to variables using the assignment operator(=). For example, statement x=15 assigns the value 15 to the variable x
What are the rules for entering a variable name?
*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
What are some things to note in variable names?
*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
What happens if a variable names whose value is not assigned is being used?
If a variable name is being used without assigning a value(it is undefined), then it is an error