1. A date consists of a year, month, day in the month, and day of the week.
    Illustrate how to encode this information in Python in a dictionary.

    Give Python code to print a date as "Thursday 4 February 2010" using the information in the dictionary.

    Answer:

    >>> D = {'year':2010, 'month':'February', 'day':4, 'weekday':'Thursday'}
    >>> s = D['weekday'] + ' ' + str(D['day']) + ' ' + D['month'] + ' ' + str(D['year'])
    >>> print s
    Thursday 4 February 2010
    

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

    Answer:

    Using sage:

    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 | True  | 
    False | False | True  | True  | 
    False | True  | False | False | 
    False | True  | True  | True  | 
    True  | False | False | True  | 
    True  | False | True  | False | 
    True  | True  | False | True  | 
    True  | True  | True  | True  |