Outline for February 10, 2012

Reading: §11

  1. Program to print words in a line lines.py
  2. Program to compute some statistics addup.py
  3. What you can do with lists
    1. Check membership: in, not in
    2. +: concatenation
    3. *: repetition
    4. list[a:b]: slice list from a to b−1
    5. del list[item]: delete list[item]; item can be a slice
  4. Objects, references, aliasing
    1. Assign “banana” to variables a, b
    2. For strings, one copy (a is b is True) [immutable]
    3. For lists, multiple copies (a is b is False [mutable]
    4. For lists, a = [ 1, 2, 3 ]; b = a; then a is b is True
    5. But . . . a = [ 1, 2, 3 ]; b = a[:]; then a is b is False

A PDF version is available here.
ECS 10, Basic Concepts of Computing
Winter Quarter 2012