lec-11-9

lec-11-9 - 11/9/2009 Announcements Program 5 due tomorrow....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
11/9/2009 1 ECS 10 11/9 Announcements ± Program 5 due tomorrow. ± No class Wednesday (Veteran’s day). ± Midterm review Friday. Midterm 2 Monday ± Midterm 2 Monday. ± Today – when to use what data structure, and a bit about how dictionaries work. Lists shopping = [“milk”, “eggs”, “tea”] print shopping[2] ± Items in a list are stored in order. ± Look up an item by its position. ± A list is always indexed by integers, starting with zero. ± An index which is >= the length of the list causes an error. Dictionaries ± Values in a dictionary are indexed by keys, which can be anything. ± Items in a dictionary are not in any particular order. ± Looking up a key that is not in the dictionary causes an error; check first: if “sparrow” in petDict: print petDict[“sparrow”] for loop with a list shopping = [“milk”, “eggs”, “tea”] for product in shopping: print “We’re out of”,product Variable product takes on the values of each of ± Variable product takes on the values of each of the items in the list in turn. ± Block under the for statement is executed three times. ± No index variable. for loop with a dictionary
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/14/2010 for the course ECS 10 taught by Professor Amenta during the Spring '07 term at UC Davis.

Page1 / 4

lec-11-9 - 11/9/2009 Announcements Program 5 due tomorrow....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online