CS21 In Class: week 6

functions, the stack, lists, strings, graphics library

For Thursday

Copy over new versions of two files you copied over on Tuesday:
$ cd cs21/class/week06 
$ cp ~newhall/public/cs21/week06/listOps.py .
  cp: overwrite './listOps.py'? y               # say y (yes)
$ cp ~newhall/public/cs21/week06/stringOps.py .
  cp: overwrite './stringOps.py'? y               # say y (yes)

Setting up a subdirectory for week 6 in-class work

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

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

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

$ cp ~newhall/public/cs21/week06/* .
$ ls
Thurs_functionWorksheet2.py  listOps.py    randomcircle.py  squareevens.py
Tues_functionWorksheet.py    partsmove.py  shades.py        stringOps.py

Weekly In-class Examples

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

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

  1. Finish the randomcircle function from last week.

  2. Look at and run shades.py and figure out what it is doing, and how it is doing it.

  3. Run colorPicker in the python interpreter to see the different available colors:
    $ python
      from colorPicker import *

  4. Look at Tues_functionWorksheet.py, trace through execution on paper, drawing the stack at two places in its execution.

  5. Look at more list and string method functions.

  6. Write a program, squareevens.py, that takes a list of int values and squares all the even values in the list.

  7. Look at Thurs_functionWorksheet.py, trace through execution on paper, drawing the stack at two places in its execution.

  8. Look at partsMove.py