python variables code example
Example 1: how to declare a variable in python
variable = 2
Example 2: python declare a variable
variable_name = 'value'
print(variable_name)
Example 3: python variables
x = str(3)
y = int(3)
z = float(3)
print(type(x))
print(type(y))
print(type(Z))
Example 4: python variables
var = 640
number = 604
tr = 623
Example 5: python variables
a = 5
b = "Varibles!"
c = True
d = False
Example 6: python variables
def scope_test():
def do_local():
spam = "local spam"
def do_nonlocal():
nonlocal spam
spam = "nonlocal spam"
def do_global():
global spam
spam = "global spam"
spam = "test spam"
do_local()
print("After local assignment:", spam)
do_nonlocal()
print("After nonlocal assignment:", spam)
do_global()
print("After global assignment:", spam)
scope_test()
print("In global scope:", spam)