python variable value code example
Example 1: python variables
x = str(3)
y = int(3)
z = float(3)
print(type(x))
print(type(y))
print(type(Z))
Example 2: variables in python
myvar = 'Variable'
Number = 9
print(myvar, Number, 'are the variables I made')
Example 3: python variable
string = 'string'
integer = 5
boolean = True
Example 4: how to create a variable in python
variable1 = "value"
variable2 = 1000000
variable3 = 10000.0
variable4 = True
Example 5: 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)