Week 12
Loop before you Leap (Loops, part 2)

Weekly Summary

Recall from our last week that that we reminded ourselves of the definition of loops as:

This week we will expand our work to include loops that process Strings (an ordered sequence of characters) and Lists (an ordered sequence of data). These are not only common data structures in programming, but are often the types of data structures that "require" the use of loops in order to most efficiently solve the problems.

 

Learning Outcomes

By the end of the week students should be able to:

  • Explain and/or properly use the following details of working with Strings and Lists:
    • How to identify the length of a String or list using - len()
    • How to identify a single item in a String or a List using indices - myString[index] or myList[index]
    • How to access a slice of items in a String or a list - myString[index1:index2] or myList[index1:index2]
    • How to create an empty list - mylist = []
    • How to create an empty String - myString = ""
    • How to "add to" a list - myList.append(newItem)
    • How to "add to" a String - myString = myString + newString
  • Reading Code
    • Given a snippet of code that includes a String, indicate the results of the code.
    • Given a snippet of code that includes a List, indicate the results of the code.
  • Writing Code
    • Given a problem statement that includes the name of a function and the parameters required by that function, write the Python code/definition of the provided function such that it solves the problem by returning correct output values.
  • Debugging Code
    • Given a problem statement and a non-working Python function that attempts to solve the problem, identify where the function is incorrect and explain how to fix it.

 

Learning Materials

POGIL Materials from the CoP

Prior to starting this week's materials you should make sure that you have done some activities that were completed at the Community of Practice event on Saturday, November 2nd. These include:

 

Textbook Readings

This week consists of two chapters from the textbook. But DON'T PANIC. A significant portion of this was covered in the POGIL activities already. Take your time and work through this material carefully.

 

Lesson Videos

In many of the following activities I will start by giving you the description of a program that you COULD try to write. If you do this, I strongly encourage you to give this an honest effort. Most of you will succeed. When you are done, or if you hit a stumbling block and can't finish it, you can/should watch the followup video where I show you how I would do this. This is kind of a step between the lesson videos and the paired programming activity. I want you to think about the problem. But I also will use these as a way to teach you something "new."

Again, use these in whatever manner most helps you. If you it helps for you to try it first, do that. If you would rather treat them as striaght out lecture videos, no problems.

 

 

Practice Materials

Paired Programming Activity

Please complete the following Paired Programming activity with your assigned partner for the week.

 

Additional Textbook Activities

These are great for some additional practice. You should complete these on your own rather than with a partner.

 

Code Walkthroughs

The following are videos and code solutions for the programs discussed in the Paired Programming Activity and Individual Program Activity. You SHOULD NOT view these until you have either solved the activities yourself - and you want to see how I would do it - or you have tried at least two different times and still are stumped. Don't jump to reading the "correct answer" too quickly. I think it is a GOOD thing to struggle with a problem for a day or two. We improve when we meet and overcome resistance. Learning comes from practice. You need to TRY before jumping to the solutions.

 

Graded Materials

The following programs are formally graded as problem set 3.2 and are here to assess your progress/competency as a solo programmer. You should work on these individually. While working on these problems, you may refer to your notes, textbook, any programs you wrote, and my videos. However, you should significantly restrict your discussions with classmates. It is moderately acceptable to discuss how you solved a problem in general terms, but you should never show your code to a classmate, whether you are the one struggling or the one helping. You can talk about ideas, but not specific solutions.

You should not be using an AI to assist you with these assignments. Dependence on these will almost certainly come back and hurt you when you take controlled programming competency demos later in the course.

Don't forget about the concept of Rubber Duck Debugging. If you are getting stuck this week you should absolutely pull out your rubber duck and talk to it. YES, you will feel foolish at first. But, again, the research shows that by talking out loud you can often (not always, but often) figure things out on your own. TRY IT!