Session 15 Preparation — Videos, Reading and Quizzes

Quizzes:

Do this Quiz on Session 15 as you watch the videos and do the reading (as listed below). This document is a Microsoft Word document; here is the same Quiz on Session 15 (pdf) as a PDF.

You can either:

In either case, bring paper copy of the completed quiz to your Session 15 class.

Videos and Reading (online and textbook):

All of the following are required except any items labeled Optional are, well, optional (i.e., things that may be interesting but do not directly pertain to your success in this course).

  1. Lists Operations
    • Textbook reading: Re-read Section 2.4 - Strings (pages 48 - 54, 7 pages).

      We have already encountered many things from this section, but there are several new things in this section as well. As you read, focus your attention on:

      • What is a string literal? What are the two notations for string literals? What is the empty string? (page 49)
      • Concatenation ( + ) and repetition ( * ) operators. (pages 49-50)
      • The int, float and str to convert strings to numbers and vice versa. (page 50)
      • Strings are sequences of characters. Indexing into the sequence and the len function (as for other sequences). (pages 50-52)
      • String methods. (pages 52-53)
      • Representing strings in a computer: ASCII and Unicode. The chr and ord functions. String escape sequences. (pages 53-54)

  2. String methods
    • Online reading: Skim Python's string methods: Section 4.7.1 of the online Python documentation.

      At first, just skim the list to get an idea of the rich collection of methods that are available.

      Then, read and digest the details of the following string methods described at the above link:

      • capitalize
      • count
      • find and index
      • isalpha and other is ... methods
      • split and join
      • strip
      • replace
      If you do not understand some of these methods from the brief descriptions at the above link, google to find examples as needed.

  3. String summary
    • Optional online reading: The Strings chapter from the online textbook Learning with Python 3

      This is an excellent, concise summary of strings. It covers ideas scattered across your textbook.

  4. String formatting
    • Online reading: the format method, as described in Section 8.16, the string format method, at Learning with Python 3 . (Scroll down the page to Section 8.16.)

      Don't try to memorize details from this section. Instead, just get the basic idea and refer back to this (and to the documentation at python.org) when needed.