Outline for December 5, 2012
Reading: § 15
Assignment Due: Friday, December 7, 2012 at 11:55 PM
- Review session announcements
- Last day of class is on Friday, December 7, 2012
- Final exam is on Thursday, December 13, 2012 in the usual lecture room (3 Kleiber)
- Review sessions:
- Monday, December 10, 2012 at 1:00pm–2:00pm in Giedt 1001
- Wednesday, December 12, 2012 at 10:30am–11:30am in 3 Kleiber
- Tuple
- Ordered list of elements
- Just like a list, but immutable
- Simultaneous assignment an example of it
- Review: file I/O
- Reading in the whole thing [fileio1.py]
- Reading line-by-line: for loop [fileio2.py]
- Writing to a file: write method [fileio3.py]
- Writing to a file: print and file= [fileio4.py]
- How to Write a Program: Bottom Up
- 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
- Step 1: write a program that generates dart tosses (actually, where they hit the board) [mc-1.py]
- Step 2: write a program to determine if a point in the square is in the unit circle [mc-2.py]
- Step 3: write a program to read in a positive integer, and reject anything else [mc-3.py]
- Step 4: now pull it all together [mc.py]
A PDF version is available here.
|
ECS 10, Basic Concepts of Computing
Fall Quarter 2012
|