In Class: Week 5


Run update21 to create a week05 subdirectory and copy example programs to your cs21 class directories. From there, move to your week05 directory:

    $ update21
    $ cd
    $ cd cs21/class/week05
    $ pwd
        /home/your_user_name/cs21/class/week05
    $ ls
      biggest_circle.py  example_funcs.py  squares.py
      draw_shapes.py     partsmove.py      squares_list.py
	

We are going to do some of the following together in class:
  1. open partsmove.py. Together we'll see how we can get a list of circles to all move using a for loop. On your own, see if you use this process to animate the movement of all the circles across the window

  2. open example_funcs.py in vim. We will look over the code which contains calls to four functions, each is an example of functions that do or do not take input values and functions that do or do not return a value. Once we think we understand what the program is doing, lets try running it.

  3. open squares.py. Together we are going to write a function square_the_biggest that takes two input values and returns the square of the larger of the two values. Let's make sure to test it for different input values to be sure it is correct.

  4. open squares_list.py. Together we are going to write a different version of square_the_biggest. This version takes a list of input values, and returns the square of the largest value in the list. Test it out on your own.

  5. open biggest_circle.py. See if you can write a function to pick out and return the circle with the largest radius. Once that is done, call the function and use the result to color the largest circle red.

  6. open draw_shapes.py and see if you can use functions to generalize the process of creating a triangle using functions.