DOC PREVIEW
Duke CPS 006 - Lecture

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Compsci 06/101, Fall 2010 11.1 What's ahead in Compsci 6/101?  Software architecture and design, why Jotto has modules and how communication works  We write small programs, want to understand some principles of larger programs  Software design in the small and in the large: different!  Dictionaries: associating keys with values  Arguably the most useful method for structuring data  How does Google find 'good' sites for a query?  How do we find what region in a genome encodes a protein?  How do we determine literary/other fingerprints? Compsci 06/101, Fall 2010 11.2 Jotto: The Program Architecture  You write jottoModel.py  This is the guts, brains, state of the program  Keeps track of how the game is progressing  Functions in the module communicate via global state  We provide two views: command-line and GUI  These all you to view and control the model  Both view-controllers: jottoMain.py and jottoGui.py know about the model, but model doesn't know about them  Model-View or Model-View-Controller  Often the model knows there is/are view(s) not Jotto Compsci 06/101, Fall 2010 11.3 Maria Klawe Chair of Computer Science at UBC, Dean of Engineering at Princeton, President of Harvey Mudd College, ACM Fellow,… Klawe's personal interests include painting, long distance running, hiking, kayaking, juggling and playing electric guitar. She describes herself as "crazy about mathematics" and enjoys playing video games. "I personally believe that the most important thing we have to do today is use technology to address societal problems, especially in developing regions" Compsci 06/101, Fall 2010 11.4 Useful Computer Science  http://maps.google.com/maps?f=d&source=s_d&saddr=300+W+Morga n+St,+Durham,+NC+27701+(Blue+Coffee+Express)&daddr=2324+Duke +University+Road,+Durham,+NC+27708&hl=en&geocode=FcNJJQIdYw5 M-yGT6vAZOfvdQg%3B&mra=ls&sll=36.088126,-79.01786&sspn=1.333 898,2.11212 Blue Coffee Express Durham 2324 Duke University RoadCompsci 06/101, Fall 2010 11.5 How does this work?  http://tinyurl.com/d5o8mr Compsci 06/101, Fall 2010 11.6 What is a dictionary, map, hash, table?  Abstraction: collection of (key,value) pairs  What kind of ice-cream do you like?  You are the key, ice cream is the value Robert Susan Jeff Alex Bruce Sam Compsci 06/101, Fall 2010 11.7 What does this code do? How? def fileStatsList(filename): file = open(filename) statList = [] for word in file.read().split(): found = False for pair in statList: if pair[0] == word: pair[1] += 1 found = True break if not found: statList.append([word,1]) file.close() return statList Compsci 06/101, Fall 2010 11.8 Faster, Cheaper, Totally in Control def fileStatsDictionary(filename): file = open(filename) stats = {} for word in file.read().split(): if word in stats: stats[word] += 1 else: stats[word] = 1 file.close() return statsCompsci 06/101, Fall 2010 11.9 Accessing map  Index a map by a key, using […]  Like indexing a list, but index is a string, …. not integer!  Works internally by associating a number with the key  This association is known as hashing the key  Methods for dictionaries:  .clear(), .get(key), .get(key,default)  .keys(), .values(), .items()  When using iteration or x in d, we're talking keys  Iterate over keys, query about keys, and so on Compsci 06/101, Fall 2010 11.10 Literary Fingerprint  Timing and playing with code in fingerPrint.py  How do we find out how fast this is?  How do we change the format of the output?  Can we organize output differently?  How can we find 'other' fingerprints  Shazaam, genome, images  What will be the key, what will be the


View Full Document

Duke CPS 006 - Lecture

Download Lecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?