list is an important data structure that allows us to store multiple values under one name, similar to how we can store multiple characters (e.g., letters) in one
string. In fact, both lists and strings are sequences, a category of types for positionally ordered collections of items. (E.g., a string is a collection of characters ordered by the indices, 0, 1, 2, ..., n-1, where n is the length of the string.) We also introduce another sequence called the
tuple, but our focus will be on lists since the
list is more flexible.
tupleis a simple sliceable type
listis one of Python's most useful built-in types. A list is mutable, unlike a string or a tuple.
listmethods, some of them you have seen before when we discussed strings.
shapes.py (to provide class
Point3, same as Lecture 7))
To download the above .py files, right-click (Windows) or command-click (Macs) on the filename and then select "Save link as".
This way you choose where the files will be saved, instead of having your computer save to the default folder (from which you will later have to move your files for organization).
Answers to the questions on slides 11, 13, 17, 21, 23, 28, and 30: See the lecture slides file above for the questions. After solving the problems yourself, you can check your answers here.