Home
Alexander Lu
Cancel

CS61A: Lecture 15

Iterators List Practice silver = [1, [3]] gold = [2, [4,5]] plat = chain([6, [7,8]]) = [6, [7,8]] [1,2,3] [1, [2,3]]

CS61A: Iterators

Iterators Most forms of sequential data are implicity represented with an iterator. Iterators are a programming interface that are used in python to access the elements of various containers. ...

CS61A: Mutability

Objects Objects are values that behave like what it’s supposed to represent Ex: datetime module from datetime import date date datetime.date In datetime, date is a class that literall...

CS61A: Lecture 14

Mutability In the way that names refer to values, we can have multiple names refer to the same values The names declared within functions may also refer to values outside of the scope...

CS61A: Trees

Trees A data abstraction used for representing hierarchical relationships. Two different metaphors of a tree: Recursive description (wooden trees): ...

CS61A: Data Abstraction

Data Abstraction Compound objects combine objects together A date: a year, a month, and a day A geographic position: latitute and longitude An abstract data type lets use ...

CS61A: Lecture 13

Data Abstraction Not inherently implemented within the python interpreter. A set of behaviors defined by the programmer. We may refer to the data and the parts without any worry about...

CS61A: Lecture 12

Manipulating Lists Making a list with a list literal Get a certain element using item selection Get a portion of the list using slicing Make a longer list using addition s = [4, 7, 9, 11...

CS61A: Lecture 11

Manipulating Lists Making a list with a list literal Get a certain element using item selection Get a portion of the list using slicing Make a longer list using addition s = [4, 7, 9, 11...

CS61A: Lecture 11

Containers List Comprehension practice First in Line Implement promoted, which takes a sequence s and a one-argument function f. It returns a list with the same elements as s, but with all ele...