CS21 In Class: week 7

functions, nested loops, lists, strings, top-down design, (and maybe file I/O)

Setting up a subdirectory for week 7 in-class work

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

$ mkdir week07                      # make a subdirectory named week07   
$ cd week07                         # cd into it
$ pwd           

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

$ cp ~newhall/public/cs21/week07/* .
$ ls
filetest.py  functionWorksheet2.py  partsmove.py    stringOps.py
foo.txt      listOps.py             primefactor.py

Weekly In-class Examples

This week we are going to continue to write functions, draw the stack and trace through function calls, write functions that take different types, including strings, lists, and graphics objects, and possibly look at file I/O.

We are going to do some of the following together in class:

  1. Go over functionWorksheet2.py from Thursday last week.

  2. Look at the partsmove.py program. See what it is doing, and see where some functions could come in handy.

  3. Together, write a couple version of a function to find the prime factors of a given number. primefactory.py.

  4. We are going learn about the Top-Down Design problem solving strategy, and then use it to start solving and designing a solution to a larger programming problem. program.
If we have time, we will look at some examples of reading in values from a file, and just as a reminder some examples of using lists and strings, and some of their methods:
  1. filetest.py

  2. listOps.py, stringOps.py: some list and string examples. Examples converting lists to strings and strings to lists. Some example methods of str and list objects.