Outline for October 8, 2012

Reading: § 4
Assignment Due: October 12, 2012 at 5:00PM

  1. Iteration
    1. Definite loops: execute a specific (definite) number of times
    2. Indefinite loops: execute until a general condition is false
  2. For loops
    1. General form: for i in iterator
    2. Iterator is either list or something that generates a list
    3. Very common form: for i in range(1, 10)
  3. range() in detail [for.py]
    1. range(10) gives 0 1 2 3 4 5 6 7 8 9
    2. range(3, 10) gives 3 4 5 6 7 8 9
    3. range(2, 10, 3) gives 2 5 8
    4. range(10, 2, -3) gives 10 7 4
  4. Program: counting to 10 [toten.py]
  5. Program: sum the first 10 squares [sumsq.py]
  6. Program: Fibonacci numbers [fib.py]
  7. Decision structures
    1. If statement
    2. Executes once, based on condition
    3. Syntax
  8. Conditions
    1. Resolves to boolean value
    2. Literal booleans: True (1), False (0)
    3. Testable as true or false
    4. Relational operators
      1. Use two arithmetic expressions connected with relational operatorsto create a boolean
      2. Relational operators: >, >=, <, <=, ==, !=
      3. Precedence: resolved after arithmetic operators
      4. 6 > 2 + 3; "UCD" == "Sac State"

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