In Class: Week 7 Monday


Create a week07 subdirectory in your cs21/class directory, and from within your week07 subdirectory copy over some python files from my public directory:

    $ cd 
    $ cd cs21/class
    $ pwd
      /home/your_user_name/cs21/class
    $ mkdir week07        
    $ cd week07
    $ pwd
      /home/your_user_name/cs21/class/week07
    $ cp ~newhall/public/cs21/week07/* .
    $ ls
	
After we work on in-class assignments together, you can copy over the code I wrote in class:
	$ cp ~newhall/public/cs21/week07/tia* .
	
My solutions are in files with the prefix tias_.
We are going to do some of the following together in class:
  1. open primefactors.py in vim. We are going to write two version of the print prime factors function. One version will use nested loops (one loop inside another loop).
  2. strings and lists as objects:

    On the class schedule for week6 is a link to information about using strings and lists as objects, and about using the random library.

    We have talked about lists and strings as being objects and how to see a listing of the methods each provide. In the python interpreter, you can get information about list and str class method functions by calling help(class_name):

      $ python
      >>>  help(str)
      >>>  help(list)
    	

    The files listOps.py and stringOps.py show some examples of using list and string method functions.

  3. Let's add a new function to primfactors.py that returns a list of prime factors of a given number. In this version, each unique prime factor will occur only once in the list. For example, if the given number is 36, the function will return a list consiting of two values (2 and 3) because 36 = 2*2*3*3.
  4. The random library. Off the class schedule for week 6 is information about the random library. Let's take a look at this and then open the file randOps.py to see some examples of how to use the random library