3.8 Iteration and 3.10 Lists - Key Points
Some key takeaways for both of the lessons.
Overview
In this post, we go over the key points you need to know about lists and iteration. In general, we start with lists since understanding lists is an important step in understanding iteration.
3.10 - Lists
Here are some key takeaways.
- Lists are a good way to organize and collect data in a program, as they allow a set of potentially very different items to be found within one object.
- Items in lists are located with indexes, which, in most code languages, start with 0 (though the pseudocode used by CollegeBoard usually starts at 1!).
- Using functions like
append()
,pop()
, andinsert()
, you can add new things to a list or remove them. - Keeping items within lists allow you to apply a function to each item of a list using iteration.
3.8 - Iteration
Here are some key takeaways.
- Iteration is the repetition of a function. Allowing a function to repeat on its own based on various conditions can vastly optimize a program.
- Iteration is most often done with loops, typically in combination with lists and/or dictionaries.
- There are multiple types of loops, and while most types can, in some way, do the same thing as other types, some things are simpler to do with certain loops than others.
- Iteration and loops go together like bread and butter.