1. An address consists of a street name, number, state and zip code.
    Illustrate how to encode this information in Python in a dictionary.

    Give Python code to print an address such as "851 S. Morgan, IL 60607" using the information in the dictionary.

    Answer:

    >>> D = {'street':'S. Morgan', 'number':851, 'state':'IL', 'zip':60607}
    >>> s = str(D['number']) + ' ' + D['street'] + ', ' + D['state'] + ' ' + str(D['zip'])
    >>> print s
    851 S. Morgan, IL 60607
    

  2. Consider the logical expression
       (x and not y and z) or (not x and y and not z).
    
    Write the truth table for this expression below.

    Answer:

    using Sage:

    sage: logic = SymbolicLogic()
    sage: s = logic.statement("(x & !y & z)|(!x & y & !z)")
    sage: t = logic.truthtable(s)
    sage: logic.print_table(t)
    x     | y     | z     | value | 
    --------------------------------
    False | False | False | False | 
    False | False | True  | False | 
    False | True  | False | True  | 
    False | True  | True  | False | 
    True  | False | False | False | 
    True  | False | True  | True  | 
    True  | True  | False | False | 
    True  | True  | True  | False |