Outline for April 10, 2009

Reading: §3.1–3.4


  1. Clarification from last class
    1. [1, 9, 2] is a list of 3 numbers
    2. range(1, 9, 2) is the same as [1, 3, 5, 7]
    3. range(9, 1, −2) is the same as [9, 7, 5, 3]
    4. range(0, 5, −1) is the same as [ ] (an empty list)
  2. Formatted printing using print statement (see print.py)
  3. Comments on homework
    1. Please do not turn in Microsoft Word (“.doc”) files! Save it as text (“.txt”) or as PDF (“.pdf”) and turn that in
    2. All Python source code files must end in “.py”
    3. Do your program in a file, not in the Python shell, unless specifically told to
    4. The index variable in a loop is a counter; if you can use it in the loop, great, but you don’t have to (and often do not)
  4. Data types: numbers
    1. Integers and floating point numbers
    2. Show bits, words
  5. Math library
    1. Making library available to program: “import math”
    2. Functions: sqrt(), exp(), trigonometric, ceil(), floor(), pi, e
    3. With above form of inclusion, must prefix with “math.”
    4. With “from math import *”, don’t need “math.”
  6. Program to solve quadratic equation (see quad.py)
    1. Show for x2 + 2x + 1
    2. Show for x2 + 2x + 2