Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nate Brunelle Today: Lists

Similar presentations


Presentation on theme: "Nate Brunelle Today: Lists"— Presentation transcript:

1 Nate Brunelle Today: Lists
CS1110 Nate Brunelle Today: Lists

2 Questions?

3 Last Time Loops in loops

4 Lists in lists x=[[1, 2], [3, 4, 5], [6]] len(x) -> 3 x[1] -> [3,4,5] len(x[1]) -> 3 x[1][0] -> 3 len(x[1][0]) Error

5 Example of lists in lists
Pictures are: A grid of pixels A grid is: A list of rows A row is: A list of pixels A pixel is: A list of 3 numbers (amounts of red, green blue) So a picture is: A list of lists of lists rows of pixels of 3 numbers

6 Identity, Alias Alias: another name for the same thing

7 New lists vs. Aliasing Creates a new list: Creates an Alias:
List-builder: [x, y, z] Slicing: mylist[start:end:step] Casting: list(collection) Creates an Alias: Assignment: mylist = myotherlist Invoking a function: func(mylist)


Download ppt "Nate Brunelle Today: Lists"

Similar presentations


Ads by Google