PROGRAMMING

m9/ PYTHON
REMEMBERS




Reassignment

p120 ! In Python it is legal to reassign a variable. Also, an assignmet can make two variables equal, but not permanent.
 
>>> x = 5
>>> x
5
>>> x = 7
>>> x
7

>>> a = 1
>>> b = 1
>>> a = 2
>>> b
1
... 5 lines
 
If you try to update a variable that doesn't exist, you get an error.
 
>>> y = y + 1
NameError: name 'y' is not defined

Questions    
While

        A B C D E F
🔔
1/1