Outline for December 5, 2012

Reading: § 15
Assignment Due: Friday, December 7, 2012 at 11:55 PM

  1. Review session announcements
    1. Last day of class is on Friday, December 7, 2012
    2. Final exam is on Thursday, December 13, 2012 in the usual lecture room (3 Kleiber)
    3. Review sessions:
      1. Monday, December 10, 2012 at 1:00pm–2:00pm in Giedt 1001
      2. Wednesday, December 12, 2012 at 10:30am–11:30am in 3 Kleiber
  2. Tuple
    1. Ordered list of elements
    2. Just like a list, but immutable
    3. Simultaneous assignment an example of it
  3. Review: file I/O
    1. Reading in the whole thing [fileio1.py]
    2. Reading line-by-line: for loop [fileio2.py]
    3. Writing to a file: write method [fileio3.py]
    4. Writing to a file: print and file= [fileio4.py]
  4. How to Write a Program: Bottom Up
    1. Problem: approximate the value of π as follows: toss darts at a 2×2 dart board centered at (0, 0). Then the ratio of the darts hitting the board in the unit circle centered at (0, 0) to all darts is π/4
    2. Step 1: write a program that generates dart tosses (actually, where they hit the board) [mc-1.py]
    3. Step 2: write a program to determine if a point in the square is in the unit circle [mc-2.py]
    4. Step 3: write a program to read in a positive integer, and reject anything else [mc-3.py]
    5. Step 4: now pull it all together [mc.py]

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