Variables Flashcards

1
Q

What are variables?

A

Labels you can assign to values

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

How do you assign value 5 to variable num?

A

num = 5

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

How do you assign values 3, 5, 8 to variables x, y, and z respectively?

A

x, y, z = 3, 5, 8

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

How do you change a variable’s value?

A

Just assign a different value to that variable
name = “John”
name = “Jane”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Does it matter if variables are lower or uppercase?

A

All variables should be lowercase and all constants should be CAPITALCASE.

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

What is a constant?

A

A variable whose value stays the same throughout the life of a program.

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