Chapter 3

Contents: True/False | Multiple Choice | Discussion | Programs

True/False

  1. True
  2. False
  3. False
  4. True
  5. False
  6. False
  7. True
  8. True
  9. False
  10. False

Multiple Choice

  1. c
  2. d
  3. d
  4. b
  5. b
  6. c
  7. d
  8. b
  9. a
  10. d

Discussion

  1. "By hand" values may differ slightly from Python output (shown in parenthesis).
    1. 7.4 (7.4000000000000004)
    2. 5
    3. 8
    4. illegal because sqrt cannot handle negative arguments
    5. 11 
    6. 27L
  2. Answers may vary as long as the expressions are equivalent.
    1. (3 + 4) * 5
    2. (n * (n-1)) / 2
    3. 4 * math.pi * r**2
    4. math.sqrt(r * math.cos(a)**2 + r * math.sin(a)**2)
    5. (y2 - y1) / (x2 - x1)
  3. These can be checked interactively.
    1. [0, 1, 2, 3, 4]
    2. [3, 4, 5, 6, 7, 8, 9]
    3. [4, 7, 10]
    4. [15, 13, 11, 9, 7]
    5. []
  4. These can be checked interactively.
    1. 0
      1
      4
      9
      16
      25
      36
      49
      64
      81
      100
    2. 1 : 1
      3 : 27
      5 : 125
      7 : 343
      9 : 729
      9
    3. 0 12
      2 12
      4 12
      6 12
      8 12
      done
    4. 1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      385

Programming Exercises

Code for Chapter 3 Exercises