Lesson Notes
RULE #2: DRY - Don't repeat yourself
print(5*6)
print(5*7)
print(5*8)
In the above code, what changes and what is staying the same?
Variables are like buckets for data. You can put data in it and it will cary the data around for you.
You can take the old data out and replace it with new data.
Reserved Words
class
, True
, for
, etc.
More info about reserved words...
=
- Assigns a value
Example:
my_variable = value
The assignment operater assigns the data on the right (value
) to the symbol on the left (my_variable
)
IT DOES NOT MEAN EQUALITY
myvar = 5
print(myvar*6)
print(myvar*7)
print(myvar*8)
a = 5
b = a
print(a, b)
a = 3
print(a, b)
Since variables store objects, that means all variables have a type.
myvar = “Hello”
print( type(myvar) )
myvar = 10
print( type(myvar) )
In Python, a variable’s type changes automatically with whatever data it is assigned to