CoursesAIMathCodePhysicsAbout and FAQ

TwiddleLab / Courses / Code

How a Programmer Thinks

Give exact instructions, then watch variables, ifs and loops run step by step.

Beginner · 10 lessons · Free, no account needed

Start the course

Lessons

  1. Instructions, Exactly (5 min): An algorithm is a list of exact steps that gets a job done.
  2. Variables Are Boxes (7 min): A variable is a named box that holds one value.
  3. Decisions: if (7 min): A condition like battery < 30 is always True or False (a boolean).
  4. Bugs Are Clues (7 min): An error message says where (the line), what kind (the error type) and the details.
  5. Loops: Do It Again (7 min): A for loop runs its indented body once for every value: each round is an iteration.
  6. Lists: Many Boxes in a Row (7 min): A list holds many values in order under one name: scores = [72, 45, 90].
  7. Sorting, One Swap at a Time (7 min): Sorting puts a list in order. Bubble sort compares neighbours and swaps them if they are in the wrong order.
  8. Finding Things Fast (7 min): Binary search checks the middle of a sorted list and throws away the half that can't hold the answer.
  9. Functions: Name a Recipe (7 min): A function is a named recipe: def gives the name and the steps.
  10. Build a Mini-game (7 min): input() asks the player to type something. It always gives back text.

Lessons are interactive and need JavaScript. Turn it on to play them.

Loading TwiddleLab