Week 11
Getting kind of loopy (Loops, part 1)

Weekly Summary

Recall from our prior Scratch Unit that we defined loops as:

For the next two weeks we will be looking at writing loops in Python. It takes us two weeks not because loops themselves are difficult - although there are two very distinct ways to write loops in Python - but because there are so many INTERESTING problems that involve loops.

This week we will start by looking at the two types of loops and using them with some "simple" numerical problems.

 

Learning Outcomes

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

  • Reading Code
    • Given a pre-defined range() function indicate what values are in the list produced by the function.
    • Given a snippet of code containing a for loop, indicate how many times that loop will execute.
    • Given a snippet of code containing a while loop, indicate how many times that loop will execute.
    • Given an existing function, and a set of input parameters to that function, identify the output returned by the function.
  • 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.
      • Functions will include those requiring looped behavior using for and/or while loops
  • 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

This week you will complete the following activities

 

 

Additional Practice

The following problems are entirely optional but are provided here to give you some additional practice if you are interested. You should complete these on your own rather than with a partner.

 

Graded Practice

The following programs are formally graded as part of the Unit 3 "Problem Set." You should work on these only as an individual. While working on these problems you may refer to your notes, your textbook, any programs you wrote, and even my videos. However, you should limit your discussion of these programs with classmates. It is acceptable to discuss how you solved a problem in grand scheme of things, but you should never show your code to a classmate either as the person who is struggling or as the person who is helping a struggling classmate. You can talk ideas, but not specific solutions.