''' Purpose: considers how Python stores and keeps track of variables ''' # get inputs into proper form (string and integer) w = input( 'Enter word: ' ) si = input( 'Enter integer: ' ) sd = input( 'Enter decimal: ' ) print() w_type = type( w ) w_id = id( w ) si_type = type( si ) si_id = id( si ) sd_type = type( sd ) sd_id = id( sd ) # display what we found out print( 'variable w is', w_type, 'and is at', w_id, 'and when printed displays', w ) print( 'variable si is', si_type, 'and is at', si_id, 'and when printed displays', si ) print( 'variable sd is', sd_type, 'and is at', sd_id, 'and when printed displays', sd ) print() # let's cast (convert) si and sd respectively into an integer and decimal # Remember that si and sd were stored as strings because user input # is returned as a string (so the variables held strings) # so that's why we convert them to int and float :) # Memory locations aren't "randomly" chosen per say... # rather the memory location is taken from the amount of allocated # memory available in your computer and it picks one of those off # and gives your variables/values one of the memory locations from # memory. It kinda has its own mechanism to determine how to # determine memory location. # For the most part, we will have you determine # whether two types/ids are the same/different and go from there # in future problems :) More on this later in the course! # Computers/computer memory are all different so your ids will # probably look different from ours. i = int( si ) d = float( sd ) i_type = type( i ) i_id = id( i ) d_type = type( d ) d_id = id( d ) # display what we found out print( 'variable i is', i_type, 'and is at', i_id, 'and when printed displays', i) print( 'variable d is', d_type, 'and is at', d_id, 'and when printed displays', d )