Decisions Tree Coding

Replace each diamond with:

if <test>:
    #right or yes branch
else:
    #left or no branch 

Solution

Modules and Loading

main()
if __name__=='__main__': main()

Example

Exception handling

See example in book
Discover error type and message by creating error in interpreter
E.g.,

>>> a, b, c = 1, 2, 3, 4

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
a, b, c = 1, 2, 3, 4
ValueError: too many values to unpack

Type is ValueError and message is too many values to unpack

Example

Truth Tables, Boolean Algebra & Boolean Functions

Truth Tables enumerate all possible combinations—be systematic

Parentheses first,
then algebraic expressions,
then the relational operators,
then not,
then and,
then or

Returning True or False

It is okay to return True or False from a function and call the function in a test.
See example.