Block F

Quiz tommorrow.

Dictionaries

With lists or tuples, we can index with integers. How about being able to index on objects into a collection? This is what a dictioanry does.

It is Python's second hashed type.

< h2>Python Boss Statements
We know the basic Python types
We know varialbes can poiint at object

All of our programs run in seriatum.
Boring.

Can we select code to run?  can we run code conditionally?
Can we have code run repeatedly?
Can we "visit" evey item in a collection?
Can we remember a procedure under a name?

def = "to define"
we use it when making functions
variables made inside of functions are invissible outside
(scope)

Python has function scope.

Math time!

What is a function?

D, a domain, which is its allowable inputs
R, the codomain, which is all allowable ouputs
f, a rule that associates each x ∈ D with some f(x) ∈ R.

Key item:  A mathematical function is consistent.  The same
input yields the same output every time.

Pure function:  a mathematical function

D = all python sequences
R = integers
x → len(x)


functions have three attributes
    1.  Preconditions:  what should be true prior to calling?
    2.  Postconditions: what is true after the function is called
            a.  return value (if any, default is None)
            b.  side-effects (such as printing to the screen)