# VariablesInMemory.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-21 File created. # 2022-12-27 Converted to Python 3. # This is not a very serius program. Built-in functions type() and # id() are demonstrated here. Python language reference says that # the identity of an object, that is returned by the id() method, # can be thought of as the object's address in memory. char_variable = 'A' short_variable = 1234 int_variable = 1234 long_variable = 12345678901234567 # What was long in Python 2 is now the standard int type in Python 3. float_variable = 123.456 double_variable = 123.456 second_int = 222 third_int = 333 fourth_int = 444 print( "\n char_variable type is %s" % type( char_variable ), end="" ) print( "\n int_variable type is %s" % type( int_variable ), end="" ) print( "\n float_variable type is %s" % type( float_variable ), end="" ) print( "\n double_variable type is %s" % type( double_variable ), end="" ) print( "\n long_variable type is %s" % type( long_variable ) ) print( "\n char_variable identity is %X" % int( id( char_variable ) ), end="" ) print( "\n int_variable identity is %X" % int( id( int_variable ) ), end="" ) print( "\n float_variable identity is %X" % int( id( float_variable ) ), end="" ) print( "\n long_variable identity is %X" % int( id( long_variable ) ), end="" ) print( "\n second_int identity is %X" % int( id( second_int ) ), end="" ) print( "\n third_int identity is %X" % int( id( third_int ) ), end="" ) print( "\n fourth_int identity is %X" % int( id( fourth_int ) ) )