Generators An iterable is any sequence we can iterate over (we may clal iter() on the iterator and get an iterator) An iterator allows us to iterate over any iterable sequence (we can call nex...
CS61A: Lecture 16
CS61A: Generators
Generators A special form of an iterator that is returned from a generator function. The generator object iterates over all yielded values of a function. In the generator funtion, we ...
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...