Skip to content
Hi, Bot

Hi, Bot · First Principles · Phase 1: Logic, functions, symbols

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

Start at lesson 1 and work up to this one

48 lessons, one a day. Answer each lesson's question correctly and the next one opens immediately — nothing here is unlocked by waiting.

By submitting, you agree to our Terms and Privacy Policy.