In Class: Week 6


Create a week06 subdirectory in your cs21/class directory:

      % cd 
      % cd cs21/class
      % pwd
        /home/your_user_name/cs21/class

      % mkdir week06        
	
Then, from within your week06 subdirectory copy over some python files from my public directory:
    % cd week06
    % pwd
      /home/your_user_name/cs21/class/week06

    % cp ~newhall/public/cs21/week06/* .
    % ls
	

We are going to do some of the following together in class:
    Practice with while loops
  1. open syracuse.py in vim. We will finish the code in main to compute the Syracuse sequence for an integer value entered by the user.

  2. open fivequestions.py. We will write the getYesOrNo function together.

  3. open primefactors.py. Together we are going to write a function that prints out the prime factors of a given number. A run of the program might look like this:
      This program prints out the prime factors of a given number
      Enter an integer value: 60
      The prime factors of 60 are:
      2, 2, 3, 5,
    		

    Some practice with functions with list and object parameters:

  4. open squareevens.py. We are going to add two functions: printList, that takes a list of integers and prints it to the terminal; and squareEvens that takes a list of integers and squares all the even elements in the list.

    Now let's change squareEvens so that it returns the number of elements it changed in the list.

  5. open changecircle.py. We are going to write a function, that takes a Circle object, a color and x and y coordinates, and moves the circle to the x, y coordinate and changes its color.

    strings and lists as objects, and the random library:

  6. On the class schedule for week6 is a link to information about using strings and lists as objects, and about using the random library. Read through this, and look at the sample code that you copied over from my week06 subdirectoy. We will talk about using lists and strings as objects in class, but you may want to look at this and try out some of the example code you copied over (stringOps.py, listOps.py, randomOps.py).