CS21 In Class: week 9

lists of lists (2D lists), list algrorithms: searching

Setting up a subdirectory for week 9 in-class work


cd into your cs21/class/ subdirectory and create a new directory named 'week09', then cd into that directory:
$ cd cs21/class                     # cd into your cs21/class subdirectory
$ pwd	          
  /home/your_user_name/cs21/class

$ mkdir week09                      # make a subdirectory named week09   
$ cd week09                         # cd into it
$ pwd           
  /home/your_user_name/cs21/class/week09

Now copy over all the files from my public/cs21/week09 directory into your week09 directory (remember to add the dot as the destination of the cp command). From your week09 directory:

$ cp ~newhall/public/cs21/week09/* .

Weekly In-class Examples

This week we are going to look at lists of lists and some operations on lists.

  1. We are not going to do this in class, but try out this star_nestedloops.py problem on your own. It requires a nested loop pattern. See if you can get this. I'll show you a solution next week.

  2. In listoflists.py is an example of creating and accessing elements in a list of lits. Let's look at this together, answer the questions about type, and we will run it and see what it is doing.

  3. In gradebook.py we will look at starting a much larger example that creates a lists of lists by reading in values from a file, and then contains a set of functions that access the list of lists in different ways. We will implement some, but not all, of the functions in this file.

  4. Using the starting point file list_algs.py, we are going to implement some operations on lists:
    1. First, we are going to add a function to find an element in a list of integer values.
    2. Next, we are going to think about how many steps this algorithm takes.
    3. Finally, we are going to think about a better way to implement this function (an algoritm with fewer steps).