<<

Agenda

• Announcements • Structure • APT Membership and for loops

1/14/2013 CompSci101 Peter Lorensen 1 Variable High level Type Modules Value Functions( ) Functions( ) Datastructures code Variables (String) Datastructures List Control structures Set Tuple Dictionary

Control structures If For loop While loop (Exceptions) 1/14/2013 CompSci101 Peter Lorensen 2 Objects – a teaser def load_lines(filename): lines = [] f = open(filename) for line in f.readlines(): line = line.strip() lines.append(line) return lines

File Object file.read([size]) Read at most size bytes from the file (less if… file.readlines([sizehint]) Read until EOF using readline() and return a list… file.seek(offset[, whence]) Set the file’s current position, like stdio‘s fseek()… file.write(str) Write a string to the file. There is no return… ...... 1/14/2013 CompSci101 Peter Lorensen 3

APT MemberShip

1/14/2013 CompSci101 Peter Lorensen 4 APT MemberShip def whosDishonest(club1, club2, club3): guilty = set() # Empty set to be returned """ Making a list of clubs converted to sets""" allClubs = [ set(club1), set(club2), set(club3)]

for redIndx in range( len( allClubs) ): for greenIndx in range(redIndx, len( allClubs)): common = allClubs[redIndx] & allClubs[greenIndx] A guilty = guilty.union( common )

for redIndx in range( len( allClubs) ): for greenIndx in range(redIndx+1, len( allClubs)): common = allClubs[redIndx] & allClubs[greenIndx] B guilty = guilty.union( common )

for redIndx in range( len( allClubs) ): for greenIndx in range(redIndx, len( allClubs)-1): common = allClubs[redIndx] & allClubs[greenIndx] C guilty = guilty.union( common )

return list( guilty ).sort()# Converting to list and sorting 1/14/2013 CompSci101 Peter Lorensen 5 • RCS professor of at MIT – Twice Godel Prize winner – Grace Murray Hopper Award – National Academy – Co-inventor of zero-knowledge proof protocols Work on what you How do you convince someone that you know [a secret] without revealing the like, what feels knowledge? right, I now of no • Honesty and Privacy other way to end up 1/14/2013 CompSci101 Peter Lorensen doing creative 6 Turing Award

• Given by the Association for Computing Machinery (ACM) • Given to "an individual selected for contributions of a technical nature made to the computing community". • "The contributions should be of lasting and major technical importance to the computer field“. • The Turing Award is recognized as the "highest distinction in Computer science“ and "Nobel Prize of computing".

1/14/2013 CompSci101 Peter Lorensen 7 • Professor of computer science at MIT – Godel Prize winner – Fellow of the IACR – Co-inventor of zero-knowledge proof protocols How do you convince someone that you know [a secret] without revealing the knowledge?

1/14/2013 CompSci101 Peter Lorensen 8