Outline for October 1, 2012
Reading
:
none
Assignment Due
: October 12, 2012 at 5:00PM
IDLE
How to use it
How to start, open a new window
Python shell, prompt
Python, files and shells
Python: programming
language
that you use to tell the computer what to do
Shell: what you can type Python statements directly into, to see what they do
IDLE: the program that
interprets
Python statements (executes the Python program)
File: type Python statements into this, and then have IDLE execute those statements by running the program in the file
Example using IDLE: hello, world
Explain printing
Demonstrate program in IDLE
Second example: compute 2 + 2, properly labeled [
twoplustwo.py
]
Difference between
"2 + 2"
,
2 + 2
Print statements usually end lines
Getting print statements not to end lines
Exceptions [
divby0.py
]
Division by zero
How you handle it
Third example: chaos program, incomplete version [
chaos.py
]
Comments
Function
input()
gets input as a string from user
Function
float()
converts data to a floating point number
Assignment to variable; evaluate right hand side first
For loop generally
Built-in
range()
function
Index variable
i
initialized to 0
Expression using multiplication, subtraction, and variables
Printing a number
Behavior with initial values of 0.25 and 0.26
Lack of error checking: what happens if I enter −0.01?
A PDF version is available here.
ECS 10, Basic Concepts of Computing
Fall Quarter 2012