Outline for January 13, 2012

Reading: §2
  1. Python, files and shells
    1. Python: programming language that you use to tell the computer what to do
    2. Shell: what you can type Python statements directly into, to see what they do
    3. IDLE: the program that interprets Python statements (executes the Python program)
    4. File: type Python statements into this, and then have IDLE execute those statements by running the program in the file
  2. Example: program to convert temperature \program{tempcvt.py}
    1. Do we go from Fahrenheit to Celsius, Celsius to Fahrenheit, or both?
      1. Go from Celsius to Fahrenheit
    2. Steps in the program:
      1. Ask user for temperature in Celsius
      2. Convert to Fahrenheit (F = (9/5)C + 32)
      3. Print result in Fahrenheit
    3. Implementation (line by line)
  3. Type converter functions int, float, str
  4. Expressions
    1. Operators +, -, *, /, //, %, **
    2. Precedence
      1. Parentheses for grouping ((, ))
      2. Exponentiation (**); associates right to left
      3. Positive, negative (unary +, -)
      4. Multiplication, division, integer division, remainder (*+, /, //, %)
      5. Addition, subtraction (binary +, -)
      6. In general, operators of equal precedence are evaluated from the left to the right (associativity); exception noted above
  5. Simple assignment: variable = expression
  6. Input: input statement
    1. input(prompt) prints prompt, waits for user
    2. When user hits enter, it returns what was typed as a string

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