''' Names are mutable untyped references.  Demo '''

# var1 would be a valid name.  I put # before it because it does not refer to anything.
# If you were to try to use a name that does not refer to anything, you would get an error message.
# var1

# This is better.  var1 is now a reference to 4
# 4 is an object of type int
var1 = 4

# The reference can be changed.  Names are mutable.
# int objects are immutable and cannot be changed.
var1 = 5

# now var1 refers to an int object with the value 5
# What happened to the object with the value 4?
# The object with the value 4 is no longer used.  It is just garbage.
# Python collects the garbage when it needs to reuse the space.  You do not need to do anything to make this happen.
# The garbage truck comes to my house on Thursday and collects stuff for recyle and junk.  I do not worry about it.

# You can use the value refered to by var1
var1 = var1 + 1

# now var1 refers to the int object with value 6
print(var1)             # result:  6
print( type(var1) )     # result: <class 'int'>

# var1 is an untyped reference so we can set it to refer to a different type
var1 = 1.414
print(var1)             # result: 1.414
print( type(var1) )     # result: <class 'float'>

# and again with a different type
var1 = "hello"
print(var1)             # result: hello
print( type(var1) )     # result: <class 'str'>

# Summary:
# The types int, float, and str are all immutable and the values cannot be changed
# But the name is mutable and can be changed to refer to a new value
# This works differently than many other programming languages
# However the net result looks somewhat like a variable in other languages

# Understanding how this stuff works helps understanding the simple things we are doing now.
# This is interesting now, but is vital in understanding a function and a tuple
# when we see them later in the course.