Outline for October 10, 2012

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


  1. Miscellaneous
    1. Announce: you must use a function to compute the vapor pressure for homework problems 1 and 2!
    2. Review local and global variables (basic rule: do not use globals)
    3. range(-20, 51, 5) vs. range(50, -20, -5)
  2. Simultaneous assignment [swap.py]
    1. Simple assignment: variable = expression
    2. Simultaneous assignment: variableA, variableB = expressionA, expressionB
  3. Decision structures [if0.py]
    1. If statement
    2. Executes once, based on condition
    3. Syntax
  4. 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"
  5. Two-way decisions [if1.py]
    1. if-else statements
    2. One condition, two possible code blocks
    3. Syntax
    4. else very powerful when the positive condition is easy to describe but not the negative
    5. String comparison example
  6. Multi-way decisions [if2.py]
    1. Can execute code based on several conditions
    2. elif (else if)
    3. Syntax
    4. else only reached if all previous conditions false
    5. Nested if statements

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