Making Decisions and Repeating Work

Overview


In the first part, the programs you wrote were straight lines. Read some input, compute something, print one response, exit. The shape was always top to bottom, one path through the code.

In this part, that shape changes. Your programs start to do two new things:

  • Branch. Based on the input, the program goes one way or another. A short study session gets one response; a long study session gets a different one.
  • Repeat. Instead of asking once and quitting, the program keeps asking until the user says they are done. A whole afternoon of sessions fits into one run.

Once your program can collect many entries in one run, it needs somewhere to put them. Lists are the natural way to store a collection of values, and they are the next data structure you will learn.

By the end of this part, you should not only be able to write branching and looping code. You should also be able to look at branching and looping code — yours, a textbook’s, or an AI’s — and ask “what input would break this?” before running it.

The structure of this part is as follows:

A useful rhythm for this part is:

  1. read the chapters in order,
  2. complete the chapter exercises as you go,
  3. then complete the project checkpoint in Adding Choices and Repetition to Your Study Log,
  4. and finish with the recap and feedback chapter.

Finally, at the end of the part, there is a recap and feedback chapter that briefly summarizes the part and asks for feedback.