Python Programming Lecture 8, Fall 2009
http://grace.evergreen.edu/mon/asn-python.html
Some variations of the Fibonacci function
- fibfor.py - fib with definite loop and simultaneous assignment
- fibtab.py - a table version of fib
- fibfun.py - fib using a separate function
- fibrec.py - a recursive fib function - simple and slick (but inefficient)!
Definite Loops - Ch 8.1, Review
- A for loop that has a definite ending
- average1.py
- fibfor.py
While Loops - Ch 8.2
- Indefinite loop because a boolean test is used to exit the loop
- average2.py
- zeno.py
Interactive loops - Ch 8.3
- average3.py - while loop with sentinal
- average4.py - while loop with EOF sentinal
- average4a.py - add exception handling
- average6.py - sentinal loop on EOF for walking through a file
Breaking out of loops - Ch 8.5
- isPrime.py - breaking out of a loop with a return
- breaking out of a loop with a break
- post test loop
Boolean Algebra - Ch 8.4
- True, False values
- Comparison Operators return Boolean values (> >= < <= == !=)
- Boolean operators: and, or, not
- Precedence of boolean operators (p248)
- Boolean expressions using comparisons and boolean operators
- Some laws of Boolean algebra (p250)
- Watch-out-for(p255): - use while response[0] == 'y' or response[0] == 'Y'
- Tricks: (p255-56) some Python bool conversions of values.
- Tricks: Short-circuit operators (p256-57).
Homework programs - tips