posted May 12, 2014, 5:09 AM by Samuel Konstantinovich   [ updated May 12, 2014, 5:32 AM ]
Pick a partner. Everyone should have one partner, if there are an odd number of people in the class then there can be ONE group of three.  
You are responsible for your partner's actions today. If one of you doesn't do what you are supposed to do, my wrath will fall upon both of you. 

Warmup 1-3
1.What is the range of values of random.random() ?

2. What is the range of values of random.randint(a,b) ?

3. What is the range of values of random.randint(a,b)+random.random() ?

Real Question: 
4. Show a trace through each of these functions on paper (sorry no tablets/laptops this time). Determine which of them correctly inverts the dictionary. If not, explain what happens. Do not run idle to check your answers, instead: compare your answers with another pair of students.

Here is a sample dictionary and the results: (remember order doesn't matter)
 { 'a':99 , 'b':34,  'c':99, 'd':100, 'e':34 }  --> {34: ['b', 'e'], 99: ['a', 'c'], 100: ['d']}

def invert1(D):
    newD = {}
    for key in D:
    return newD

def invert2(D):
    newValues = D.keys()
    newKeys = D.values()
    newD = {}
    for i in range(len(newValues)):
        if newKeys[i] in newD:
            newD[newKeys[i]]= [ newValues[i] ]
    return newD

def invert3(D):
    q = {}
    for h in D:
    for h in D:
    return q

def invert4(D):
    z = {}
    for x in D:
        if D[x] in z:
            z[D[x]]= [ x ]
    return z

def invert5(D):
    newD = {}
    for key in D:
    for key in D:
    return newD

def invert6(D):
    newD = {}
    for key in D:
        newKey = D[key]
        newVal = key
        if newKey in newD:
            newD[newKey]= [ newVal ]
    return newD  

Time for a big project (Due Sunday. May 19th by morning)
Everyone can share ideas on what data to look at and how to look at it, as well as share cool data sources.
Everyone must document what kind of help was received for the project.

1. This will count as a significant project, more than your labs. (The time stamp of your py file on the web server should not be later than 05-19-2013 800am)

2. You will have a different file every day you work, so i can see what you did.
You will need sub-directories   v13,v14,v15,v16 or v17,v18  (You need at least two versions for the weekend)
Every night you will work on the assignment, but I only expect the 1st version Tuesday night.
Timestamps matter on each version. Runnability matters on each version. It should do something, like display the data, display the totals or something. Each version NEEDS to display something. If you break your code, fix it by commenting out the broken parts before you save it for the day. At no point should you leave your code in a broken state!!!

You may optionally work on this with a partner and collaborate in several ways:
A:    Just share ideas on data, but write separate code. Of course you can help each other with debugging code, but the code you submit should be what you wrote. This is Conceptual Collaboration, but independent implementation.
B:    Work on the coding aspect together (you need to produce more (extra features, more analysis) also it is necessary to delegate tasks) You must document who wrote what portions of the code. You may not just write one program with two of you sitting at the keyboard. You are producing more than 1 person worth of code. (I have higher expectations)
C:    Ask me if you want to work with some other arrangement. 

1. You will make a folder for this project and all of the data you use
There will be subfolders for every day of work. Each subfolder should have some working code. 

2. You will save one or more data sets in the directory, as data1.___ data2.___,etc they can be txt csv or other file types. You may optionally make some test data sets, smaller ones that work with older versions of your program for debugging purposes. 

Heading To Use:


LastName, FirstName




DATASET: _______

DATA SOURCE: _______

Chosen because...



3. You will make a file data.py  that will generate 

an HTML page containing:

  • Heading & explanatory paragraphs (Why did you choose this dataset to explore? Background the reader should know? Etc...)

  • Data table (you can format and colorize it as you see fit, but don't randomize colors)

  • Citation & link to data source. (Name of source and link to page where CSV file can be downloaded)

  • Link to analysis.py

4. You will make a file analysis.py that will generate an HTML page containing:
  • Heading & background paragraphs (How did your exploration evolve? Key insights? Turning points? Obstacles encountered/overcome? Etc...)

  • Table of summary newly created data (avgs, sums, areas of overlap between datasets, etc. that you used python to calculate)

  • Link to data.py

  • Summary/Conclusion paragraphs. (Aim for at least 1 pattern, notable intersection, or bizarre-or-otherwise-notable-phenomenon extracted from the data.) (What did you eventually find? Obstacles encountered/overcome? Ideas for further exploration?)

Finally. You will also link your project files in your assignments.html