Outline for November 14, 2012

Reading: § 14
Assignment Due: Wednesday, November 28, 2012 at 5:00 PM


  1. Lists
    1. Sequence of values (ints, floats, strings, other lists, etc.)
    2. Denoted by square brackets [ ] with values separated by commas
    3. Lists are mutable
    4. How to create a list
  2. Type conversion
    1. str(val) attempts to convert val to a string
    2. list(sequence) attempts to convert sequence to a list
  3. Program to print words in a line [lines.py]
  4. Program to compute some statistics [addup.py]
  5. 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
  6. Objects, references, aliasing
    1. For strings, one copy: assume a = "banana"
      1. After b = a or b = a[:], then a is b is True
    2. For lists, multiple copies: assume A = [ 1, 2, 3 ]
      1. After B = A, then A is B is True
      2. After B = A[:], then A is B is False
  7. Lists as parameters: can change list elements in function and they are changed in caller [args2.py]


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