First up: discuss the homework due today.

My sample answers are in code/homework/oct4 :

Please take these examples of mine as "good coding practice" and where you can follow this format for everything else you do this semester: docstrings, doctests (where appropriate, they aren't always), and short, clearly defined functions with clean arguments (inputs) and return value (outputs).

Any questions about anything?

Here's the schedule I have in mind the rest of the term :

- Chap 7 (decision structures) due Thu Oct 11 ... along with project proposal
- Chap 8 (booleans) due Tue Oct 23 (week after Hendrick's)
- midterm project due Tue Oct 30 (and read/discuss chap 9, simulation & design)

Then in our last month we should just about time to finish the text :

- Chap 10 (defining classes) due Nov 6
- Chap 11 (data collections) due Nov 13 & final project proposals
- Chap 12 (object design) due Nov 20
- Chap 13 (algorithms) due Nov 29
- final project presentations Dec 4 (last day of classes)
- final project code & writeup Dec 7 (Fri after that)

I will post assignment due next Thursday within the next few days - start by please reading chapter 7 this week.

I'll either just show examples or use the textbook's slides to walk through the topics in chapter 7 .

- "if" statements
- flow charts
- comparison operators : < , <= , !=, ...
- "if" ... "else" : quadratic equation example
- "if" ... "elif" ... "else" : n-way
- exceptions : "try ... "except"

Which is biggest?

First try: "if x1 >= x2 >= x3" ... Hmmm. Valid in python but *not* in most code. Also, (5,2,4) gives False; doesn't identify x1 as biggest.

Second try : "if x1 >= x2 and x1 >= x3" ... better i. More about "and" in the next chapter.

```
if x1 >= x2 and x1 >= x3:
maxval = x1
elif x2 >= x1 and x2 >= x3:
maxval = x2
else:
maxval = x3
```

or how about this instead

```
if x1 >= x2:
if x1 >= x3:
maxvval = x1
else:
maxval = x3
else:
if x2 >= x3:
maxval = x2
else:
maxval = x3
```

Draw that as a flowchart and trace through some examples.

Or we could just test each in turn ...

```
maxval = x1
if x2 > maxval:
maxval = x2
if x3 > maxval:
maxval = x3
```

This approach scales nicely to bigger collections.

In this case python has a built-in ... `max(x1, x2, x3)`

. :)