Session 3: Booleans, Sequences, Iteration, and Strings

Booleans, Sequences, Iteration, and Strings

Pre-class prep

Read: Boolean Expressions

Read: Python Sequences

Read: Iteration

Read: Strings

Supplemental Reading:

Think Python, chapters 7 – 10 (11, 12)

(http://greenteapress.com/thinkpython/html/thinkpython008.html)

Dive Into Python: chapters 3, 4

(http://www.diveintopython3.net/strings.html)

In-class Activities

Working with Booleans, Conditional Expressions, etc

Re-write a couple CodingBat exercises, returning the direct boolean results, and/or using ternary expressions.

Variable Scope

Experiment with locals by adding this statement one of the functions we wrote last week (or any other function you wrote):

print(locals())

Sequences Exercises

Slicing Lab

List Lab

String Exercises

String Formatting Exercise

(optional) ROT13

Mailroom Exercises

You’ve now got the basics of the language down – enough to write the first full “program”:

Mailroom Part 1

Post-class Activites

Finish the mailroom project.

And the other exercises

Look at the next session for reading, etc:

Session 4: Dictionaries, Sets, and File Handling