slides5-4up[1]

slides5-4up[1] - PFTRotW Review loops and lists(see...

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

View Full Document Right Arrow Icon
Compsci 06/101, Spring 2011 5.1 PFTRotW Review loops and lists (see Uppity.py again) Loop over sequence: string, file, list, "other" Process each element, sometimes selectively Toward understanding the power of lists How do we debug? What do we do when we have code, but it's wrong? How do we minimize head-beating-against-wall? Mental model of code execution and Pythonic vocabulary The power of randomness Compsci 06/101, Spring 2011 5.2 Anatomy of a Python list Create list with brackets (values optional) s1 = [] s2 = ["a", "b", "c"] s3 = list("123") #from an iterable Lists are mutable and iterable Append to list, change value stored at index s2[1] = 5, s2.append(77) for elem in list: Use function on lists: len, min, max, sum Operator: in Compsci 06/101, Spring 2011 5.3 List methods In object oriented programming methods are functions that operate on an object Inspect or change the object Sometimes return values
Background image of page 1

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

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

{[ snackBarMessage ]}

Page1 / 2

slides5-4up[1] - PFTRotW Review loops and lists(see...

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