Variables Flashcards
1
Q
What are variables?
A
Labels you can assign to values
2
Q
How do you assign value 5 to variable num?
A
num = 5
3
Q
How do you assign values 3, 5, 8 to variables x, y, and z respectively?
A
x, y, z = 3, 5, 8
4
Q
How do you change a variable’s value?
A
Just assign a different value to that variable
name = “John”
name = “Jane”
5
Q
What are the rules for variable names?
A
- no spaces
- just letters, numbers and underscore character (_)
- can’t begin with a number
- don’t use Python keywords and function names
- keep it short and descriptive
6
Q
Does it matter if variables are lower or uppercase?
A
All variables should be lowercase and all constants should be CAPITALCASE.
7
Q
What is a constant?
A
A variable whose value stays the same throughout the life of a program.