Just like cities, computer programs possess infrastructure. At a very basic level, infrastructure consists of three key components:
- Sequence
- Selection
- Repetition
Sequence
Sequence is the order in which a process is conducted. Every computer program must be organized so that steps are executed in a logical order. For example, ask your coder to order the steps in a simple algorithm. The steps include answering Rocky; saying Rocky, roll over!; and asking What is the name of your dog?Your coder should be able to recognize that you must first ask the name of the dog (query); then receive the answer (input); and then, remembering that Rocky is the name, say, Rocky roll over (output).
As a Scratch program, the algorithm looks something like this.

Understanding the order in which input and output must occur is just one example of sequence in a computer program.
Invent some other sequencing tasks for your kid to try. What about gardening, baking brownies, or washing the car? What are the most important steps of each task, and how must they be sequenced?
Selection
Selection means choosing a path based on certain conditions. For example, when choosing a university to attend, you may decide between West Coast or East Coast. The decision you make then directs you to new sequences — and consequently, other selections — that relate to your choice. If you choose West Coast, then Stanford is on your list of potential universities, but not Harvard. Program commands associated with a decision that you didn’t make aren’t executed.When coding, selection allows the programmer to create as many paths as needed to respond to the conditions of the program. Selection often involves conditional statements that are structured this way: if <em>[condition occurs></em> then <em>[execute consequence></em>
. Conditional statements can be structured in different ways, depending on what the program needs to accomplish. The image below shows three conditional command structures your coder can use in Scratch.

Here are some everyday examples, in standard English, that match the structure of the Scratch conditional commands:
if
everyone completes homework by dinnertimethen
we'll eat at Olive Gardenif
you eat orangesthen
you are a healthy pirateelse
you have scurvywait
until countdownequals
zero
The Choose Your Own Adventure app makes frequent use of conditionals. Can you and your coder think of other examples in which conditional statements are used in everyday life?
Repetition
Repetition is the process of repeating something. You may have said to your kid, “How many times have I told you to take out the trash — I just keep repeating myself again and again, arrghh!” Unlike grownups, computers are happy to repeat themselves over and over. In fact, repetition is an important task when coding, and understanding how to write code blocks that repeat is critical to structuring your computer programs.Using a repeat
command is one way your coder can create a loop in his code. A loop is a structure that tells the computer to run the same commands multiple times, without writing those same commands over and over. Like a traffic circle (which we've all been stuck on many times!), you can continue looping around, again and again until there’s a reason to eventually exit the loop. Creating a loop is similar to creating a chorus in a song: You can provide a notation that indicates a lyric should be sung eight times without writing it eight times:
repeat 8 ["Come on, be my baby, come on">Actually writing this bridge from Ed Sheeran’s “Shape of You” requires eight lines, but using code, your kid can produce the same result in a single line. Repetition rocks!
Depending on the programming language your coder is using, loops are handled somewhat differently.

Following are some examples, in standard English, that match the structure of the Scratch loop commands:
repeat 2
[apply shampoo, lather, rinse>repeat 4
[drive to the end of the block, turn right>forever
[move forward 10 steps, wait 1 second, move backward 10 steps, wait 1 second>repeat until
[the value of the jackpot exceeds $100 million>
repeat
command indicates that the steps, “apply shampoo, lather, rinse” repeat two times. The second example demonstrates how to drive a square-shaped path in your neighborhood, ending up at your starting point. Example three shows a forever
command that results in a bouncing motion that continues endlessly, until the program itself terminates or some other commands stop its execution. In the final example, the repeat until
command is a hybrid command consisting of a repeat
loop and an until
conditional. The until
conditional triggers a break out of the loop structure.
Find some favorite songs or dances that include repeated sections. Work with your kid to identify the repeated lyrics or steps, as well as how many times the repetition occurs. Can you say, “Heyyyyyy, Macarena!”