Teaching Examining and Manipulating Strings

Today I chose to teach a chapter 5 text topic.  This section essentially discussed how to navigate different strings and adjust outputs from them.  During my teaching I went over the basic structure of creating different string outputs, which I outlined as ‘string’ [ _ _ _ ]

I described how the first blank essentially tells the program when to begin, the second blank tells the program where to stop, and the last blank tells where to skip (where applicable).  In these spaces, you can have integers corresponding to the list number of each letter (0 for the first letter, ect).  If you are starting from the very beginning or the very end, you can use a colon.  And finally, if you wish to begin counting from the back, you can use a negative number (so -4 would tell the program to start 4 letters from the end).

After going over the basics of navigating strings, I was interested in further exploring skipping.  The immediate application that I could envision was using the feature to create a sort of secret code.  I encouraged my participants to create a function with what was essentially a nonsense list, where with a skip function, a message could be revealed.


The above is a copy of the example I did to demonstrate the task I had in mind.  I used ls as my filler letters to make what I was doing easier to visualize.  My group seemed pretty impressed, and I thought it was a rather neat way to apply a creative/functional task from the skip feature.  Furthermore one of my participants said she now understands this section of the book, which really pleased me as a teacher.

Our table had 3 teachers today, and I was last, so I was a bit pressed for time.  Furthermore, not everyone had immediate access to their Python programs, so I essentially had to provide the demonstration (as opposed to having all of my participants create their own personal secret code).  However, my hope is that some of my participants might be interested in exploring this task or other applications of the topic on their own time, now that I’ve hopefully provided them with the tools to successfully do so.

Leave a Reply

Your email address will not be published. Required fields are marked *