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
(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 |