minte9
LearnRemember



Assign

A variable must be assigned before use.
 
"""A variable must be assign before use
"""

y = 0
y = y + 1
assert y == 1 # pass

try:
    z = z + 1
except NameError:
    print('Variable z not defined')

Reassignment

In Python it is legal to reassign a variable.
 
"""In Python it is legal to reassign a variable
An assignment can make two variables equal, but not permanent
"""

x = 5
x = 7

assert x == 7 # pass
assert x != 5 # pass

a = 1
b = 1

assert a == b # pass

a = 2

assert a != b # pass



  Last update: 150 days ago