Functions

In class exercises
Change into your inclass directory.
[~]$ cd
[~]$ cd cs21/inclass/
[inclass]$ ls
w01-intro/  w02-numAndString/  w03-decisions/ w04-graphics/
If the w05-functions directory does not yet exist, create it using mkdir
[inclass]$ mkdir w05-functions
Copy the sample files for today from my directory using cp
[inclass]$ cp ~adanner/public/cs21/w05-functions/* w05-functions/
[inclass]$ ls
w01-intro/  w02-numAndString/  w03-decisions/ w04-graphics/
w05-functions/
[inclass]$ cd w05-functions/
[w05-functions]$ ls
draw_shapes.py  factorial.py  simplefunc.py  squares.py
[w05-functions]$
We are going to do some of the following together in class:
  1. open simplefunc.py in vim. We will look over the code which contains calls to two simple functions. Once we think we understand what it is doing, lets try running it.
  2. open factorial.py. We will look over the code together. This is an example of a function that takes input (it has parameters and the function call contains argument values for the parameters) and an example of a function that returns a value to the caller.
  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 draw_shapes.py. We are going to write some functions together.
Biggest Circle
Create a function biggestCirc(loc) that returns the circle with the biggest radius given a list loc circle objects. Write a small main function to create a list of circle objects and test your function.