Search for tag: "accumulator"

Lesson 29.3 Generators Revisited

In the previous video, we said that generators are a type of coroutine. In this video, we explore this idea. We use yield statements to write generators that are a little more sophisticated than…

+19 More
From  Hannah Lee 65 plays

Lesson 28.9 Dictionary Comprehension (OPTIONAL)

This video is not optional because the material is advanced. It is optional because this video series has run long and this topic is less important for you to know. While we have not talked about…

+19 More
From  Hannah Lee 28 plays

Lesson28.8 List Comprehension (OPTIONAL)

This video is not optional because the material is advanced. It is optional because this video series has run long and this topic is less important for you to know. When we are done with out…

From  Hannah Lee 26 plays

Lesson 28.6 map and filter

In this video we talk about two very famous generators: map and filter. We show how to use these to replace writing code with a for-loop.

+19 More
From  Hannah Lee 52 plays

Lesson 28.5 Generator Design

Now that we know how generators work, it is time to write our own. In this video we show how easy it is. We just take out experience with the accumulator pattern and replace the accumulator with a…

+19 More
From  Hannah Lee 60 plays

Lesson 26.5 While-Loops vs For-Loops

We can always replace for-loops with while-loops, but should we? In this video we talk about the trade-offs of the two control structures and why it might be better to use over the other.

+19 More
From  Hannah Lee 80 plays

Lesson 26.3 While-Loop Ranges

While-loops require additional patterns beyond the simple accumulator pattern that we used in for-loops. In this video, we talk about the first such pattern, which is replacing the range iterator.…

+19 More
From  Hannah Lee 81 plays

Lesson 26.2 While-Loop Traces

While-loops can do everything that a for-loop can (and more) but they are much harder to use. That is why, in this video, we talk about how to debug a while-loop before we talk about how to write…

+19 More
From  Hannah Lee 88 plays

Zoom Oct. 27. Nested Lists and Dictionaries

This presentation explores the last built-in (as opposed to user-defined) types in this course. These types are often used to store data in files.We actually had an (accidental) sneak peak at these…

+19 More
From  Hannah Lee 38 plays

Lesson 19.6 Immutable Dictionary Functions

Since we can loop over dictionaries, that means we probably want to use them in functions with accumulators. In this video we show how to do this and why they are not that much different from lists.

+19 More
From  Hannah Lee 73 plays

Lesson 18.5 Immutable Table Functions

In this video we show how to write an immutable function on a table of data. In most ways this is no different than writing an immutable function on a list. Except that this time we may need multiple…

+19 More
From  Hannah Lee 80 plays

Zoom Oct. 15. For-Loops

In this session, we review the for-loop, which is the next control structure. This is the last control structure we will need for a while.For-loops are pretty easy to use in Python, and most students…

+19 More
From  Hannah Lee 24 plays

Lesson 17.6 Divide and Conquer Visualization

Just because you know how to write a divide-and-conquer algorithm does not mean you understand it. In this video we try to improve our understanding by visualizing divide-and-conquer. When we do this…

+19 More
From  Hannah Lee 168 plays

Lesson 16.8 Tuple Expansion (OPTIONAL)

This video introduces an advanced topic that is completely optional and will not appear on any exam. You might have noticed that some functions, like max can take an arbitrary number of arguments. In…

+19 More
From  Hannah Lee 54 plays

Lesson 16.6 Mutable For-Loops

Lists are mutables and support mutable functions. Many of these mutable functions contain for-loops. As we show in this video, this changes how we write the for-loop. In particular, we will not use…

+19 More
From  Hannah Lee 77 plays

Lesson 16.5 Positional For-Loops

Sometimes we need to perform a calculation on a string, list, or tuple, but we do not want to loop over this value. Instead, we want to loop over the positions of the value. In this video we show why…

+19 More
From  Hannah Lee 90 plays