Outline for April 1, 2009
Reading
: §1.6–1.9
Guest Lecturer
: Justin Cummins
Administration
Show python website and textbook on Google Book Search
Mention HW1 has been released
Demonstrate Smartsite submission
Separate HW1 submission into separate files
IDLE
What is it and what to use it for
How to start/open a new window
Explain shell and “>>>” marks
First program: Hello, World
Explain printing
Demonstrate program in shell and as source code file
Second program: print “2 + 2 =”, 2 + 2
Quotes denote text rather than numbers (values)
Comma automatically adds a space and stays on the same line
Other print statements
Dividing by 0
Chaos program, line by line (se
chaos.py
)
Comments
Function definition
Tab indenting to denote being part of function definition
Function
input
() gets values from user
Assignment to variable; evaluate right hand side first
For loop in detail
Built-in
range
() function
Index variable
i
initialized to 0
Loops
Expression using multiplication, subtraction, and variables
Behavior with initial values of 0.25 and 0.26
Chaotic phenomena
Unpredictability: no simple formula for 1000
th
value; it must be computed
Sensitivity to initial parameters
Dependent on
k
-value (here, initially 3.9)