''' Purpose: introduction to dictionary' ''' mappings = {} # initializes an empty dictionary mappings[ 0 ] = 'even' # add a new mapping with key 0 mapping to the value 'even' mappings[ 1 ] = 'odd' # 1 'odd' mappings[ 2 ] = 'even' # 2 'even' mappings[ 3 ] = 'odd' mappings[ 4 ] = 'even' mappings[ 5 ] = 'odd' mappings[ 6 ] = 'even' mappings[ 7 ] = 'odd' mappings[ 8 ] = 'even' mappings[ 9 ] = 'odd' mappings[ 'even' ] = 'a number is even if its remainder divided by 2 is 0' # maps 'even' to this definition mappings[ 'odd' ] = 'a number is odd if its remainder divided by 2 is 1' # maps 'odd' to this definition # this example is not the best way to solve this problem, but shows the utility of heterogeneous dictionaries reply = input( 'Enter a number: ' ) n = int( reply ) status = mappings[ n ] print( n, status ) reply = input( 'Enter even or odd: ' ) meaning = mappings[ reply ] print( meaning )