Chapter 6 Note

Do NOT use explicit conditionals (if/else) anywhere in this lab. This chapter (6) comes before the chapter on conditionals (7), so the exercises are designed to be done without conditionals.

These functions are all one- or two-liners that should take you a couple of minutes each. In other words, if you’re stumped after a few attempts, ASK ME FOR HELP. Please DO NOT LOOK AT ANOTHER STUDENT’S SOLUTION!

You can put all your functions in a single script file myfuns.py Once you complete a function, hit the F5 key to reload your script, and test the new function with sensible input (as I will do). (If you can’t think of a sensible test, raise your handle, and we’ll figure one out together.) Your comment for each function should be the problem number (E6.1, E6.2, etc.) followed by a brief (one-line) description of what the function does; e.g., your file powersum.m would start with

  def powersum(z, n):
      """
      E6.2: computes sum of Z^-j, 0 <= j <= N
      """

Then you can do

  >>> help(powersum)

to see the help info. You can also use this comment block to answer any questions in the exercises, like “give a statement” in E6.3.

For E6.11 (using funplot with lambda) you can put the code for your three plots at the end of your script. Don’t forget show() !

Finally, before uploading your script to sakai, make sure that it loads without error when you hit F5. No matter how much work you did, you will get a zero if I hit F5 and and get an error!.