Lecture 16 - Cornell University
Lecture 16
Nested Lists and Dictionaries
Announcements for This Lecture
Prelim and Regrades
Assignments/Reading
? Regrades are now open
? Only for MAJOR mistakes ? You might lose points
? The regrade process
? Ask in Gradescope ? Tell us what to look for ? If valid, we will respond ? We will also update CMS
? Should be working on A4
? Tasks 1-2 by tomorrow ? Task 3 by the weekend ? Recursion next week
? Reading: Chapters 15, 16
? Chapter 17 for next week ? Lot of potential reading ? ... but we are covering a lot
10/22/19
Nested Lists and Dictionaries
2
Lists of Objects
? List positions are variables
? Can store base types
r id10
id13 list
? But cannot store folders ? Can store folder identifiers
b id11 g id12
x[0] id10 x[1] id11
? Folders linking to folders
x id13
x[2] id12
? Top folder for the list ? Other folders for contents
? Example:
>>> r = introcs.RGB(255,0,0) >>> b = introcs.RGB(0,0,255) >>> g = introcs.RGB(0,255,0) >>> x = [r,b,g]
id10 RGB
red 255 green 0 blue 0
id11 RGB
red 0 green 0 blue 255
id12 RGB
red 0 green 255 blue 0
10/22/19
Nested Lists and Dictionaries
3
Lists of Objects
? List positions are variables
? Can store base types
r id10
id13 list
? But cannot store folders ? Can store folder identifiers
b id11 g id12
x[0] id10 x[1] id11
? Folders linking to folders
x id13
x[2] id12
? Top folder for the list ? Other folders for contents
? Example:
>>> r = introcs.RGB(255,0,0) >>> b = introcs.RGB(0,0,255) >>> g = introcs.RGB(0,255,0) >>> x = [r,b,g]
id10 RGB
red 255 green 0 blue 0
id11 RGB
red 0 green 0 blue 255
id12 RGB
red 0 green 255 blue 0
10/22/19
Nested Lists and Dictionaries
4
Nested Lists
? Lists can hold any objects ? Lists are objects ? Therefore lists can hold other lists!
a = [2, 1] b = [3, 1] c = [1, 4, b] x = [1, a, c, 5]
x[1]
x[2] x[2][2]
x = [1, [2, 1], [1, 4, [3, 1]], 5]
x[0]
x[1][1] x[2][0]
x[2][2][1]
10/22/19
Nested Lists and Dictionaries
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- lecture 04 more iteration nested loops brown university
- evaluating nested expressions in python idc online
- list comprehensions department of computer science and electrical
- ppyytthhoonn nneesstteedd llooooppss
- chapter 3 selection statements southeastern louisiana university
- random access lists nested data types and numeral systems haskell
- lecture 6 lists nested loops and files github pages
- python if else and nested if else tutorial kart
- lecture 14 nested lists tuples and dictionaries
- about python 5 while loop
Related searches
- cornell university data analytics program
- cornell university data analytics certificate
- cornell university business analytics
- cornell university business
- cornell university johnson business school
- cornell university college of business
- cornell university college report
- cornell university reputation
- cornell university data analytics
- cornell university dyson business school
- cornell university johnson
- cornell university johnson school