""" Purpose: introduce type() and id() """ # get variable values reply = input( "Enter an in integer and a decimal: " ) n, x = reply.split() # n stores the integer, x stores the decimal n = int( n ) x = float( x ) # investigate variables type_reply = type( reply ) # since reply was handed back from an input(), we know its a string type_n = type( n ) # we cast n to an integer using the int() function type_x = type( x ) # we cast x to a float using the float() function # type() of a variable is going to return # semi-colons abound in other programming languages, they end statements id_reply = id( reply ) # these values will change everytime based on the frame of memory the computer hands id_n = id( n ) # python to run this program id_x = id( x ) # these are going to be very big numbers because computers have a lot of memory # why would we want to know where data is? i have never used this function in my CS career # display variable characteristics print() print( "reply:", reply, type_reply, id_reply ) print( "n:", n, type_n, id_n ) print( "x:", x, type_x, id_x )