A string is a sequence of text characters. We will work with strings using functions, string methods, and slicing expressions. We will also define functions that take strings as arguments.

Lessons - watch before lecture

Note: We are experimenting with different platforms for posting videos in order to find an option that works well for all our students, who span quite a few geographic regions. If the original links perform poorly (e.g., slow loading) for your locale, try the alternative links.

  1. String Functions (5 minutes) Let's look at some useful built-in functions that work with strings. (alternative link)
  2. Advanced String Expressions (12 minutes) Learn about the escape character that allows us to deal with special characters in strings. (alternative link)

AND read: 8.1, 8.2, 8.4, 8.5, and the first paragraph of 8.9 (html version)


Lecture materials

Slides: individual slides for viewing, 6-up layout for printing

Examples: lec05examples.py (skeleton), lec05examples.py, return_vs_print.py
To download the above files, right-click (Windows) or command-click (Macs) on the filename and then select "Save link as".
This way you choose where the files will be saved, instead of having your computer save to the default folder (from which you will later have to move your files for organization).

Lecture Recording

Answers to the 3 in-lecture questions (slides 14, 21, 25) and the 4 post-lecture questions at the end of the lecture slides (slides 35, 37, 39, 41): Be sure to do the post-lecture questions to check your comprehension! See the lecture slides file above for the questions. After solving the problems yourself, you can check your answers here.