Outline for January 23, 2012

Reading: §5

  1. Decision structures
    1. If statement
    2. Executes once, based on condition
    3. Syntax
  2. Conditions
    1. Resolves to boolean value
    2. Literal booleans: True, False
    3. Testable as true or false
    4. Relational operators
      1. Use two arithmetic expressions to create a boolean
      2. >, >=, <, <=, ==, !=
      3. Resolved after arithmetic operators
      4. 6 > 2; "UCD" == "Sac State"
  3. Two-way decisions
    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
  4. Multi-way decisions
    1. Can execute code based on several conditions
    2. elif (else if) introduced
    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
Winter Quarter 2012