Lesson 2 of 48
Loops and branches
Two shapes that let a short procedure do a long job.
A loop repeats; a branch chooses. Almost every program you will ever read is those two shapes nested inside each other. Get comfortable tracing them by hand now and nothing later — including backpropagation — will look like magic.
Do this
Hand-trace a loop nested inside another loop, writing down the value of every variable after each pass. Then run it and check your trace matched, line for line.
The question that unlocks the next lesson
An outer loop runs 3 times; the inner loop runs 4 times per outer pass. How many times does the innermost line run?
- A7
- B12
- C3
- DIt depends on the branch inside it