Outline for January 11, 2012

Reading: §1

  1. IDLE
    1. How to use it
    2. How to start, open a new window
    3. Python shell, prompt
  2. Example using IDLE: hello, world
    1. Explain printing
    2. Demonstrate program in IDLE
  3. Second example: compute 2 + 2, properly labeled [twoplustwo.py]
    1. Difference between '2 + 2', 2 + 2
    2. Print statements usually end lines
    3. Getting print statements not to end lines
  4. Exceptions [divby0.py]
    1. Division by zero
    2. How you handle it
  5. Third example: chaos program, version 1 [chaos1.py]
    1. Comments
    2. Function input() gets input as a string from user
    3. Function float() converts data to a floating point number
    4. Assignment to variable; evaluate right hand side first
    5. For loop in detail
      1. Built-in range() function
      2. Index variable i initialized to 0
      3. Loops
      4. Expression using multiplication, subtraction, and variables
    6. Behavior with initial values of 0.25 and 0.26
  6. Fourth example: chaos program, version 2, error handling [chaos2.py]
    1. What if the user types in a non-number?
    2. What if the user types in a bad number?

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