In this lesson
- It starts with a question. "Add 5 to the total, for each of the 4 crates." How many times does the adding happen?
- The idea you will find. Write the body once, the machine repeats it. — A loop is why a program handling four crates also handles four thousand without another line of code. Two things decide whether it is right: what it repeats over, and when it stops. Get the stopping wrong and the program never finishes.
- How you learn it. By doing: putting things in order.
- Length. 5 short steps. Progress saves on this phone.
Part of Think Like a Program
Before any language: order, repetition and conditions, written so a machine cannot misread them.