DSA Factory
All free lessons
Level 0 · Programming basics

Free Programming basics lessons

40 lessons, about 358 minutes in all. Each teaches one idea with a visual, then gives you one problem built for it. Read the lessons here, then create a free account to solve the problems and keep your progress.

Stage 0Names for values

  1. A name for a valueGive a value a name, then use the name in a calculation.7 min
  2. Changing a valuePut a new value into a box, using the old one.7 min
  3. Swapping two valuesSwap what two boxes hold, with the help of a spare box.8 min
  4. True or false valuesAsk a yes-or-no question about two values and keep the answer.7 min

Stage 1Numbers

  1. Dividing and what's leftShare things out evenly and find out how many are left over.8 min
  2. Which part first?Know which part of a sum happens first, and use brackets to choose.7 min
  3. Peeling off digitsRead the last digit of a number, and drop it.8 min
  4. Numbers have limitsKnow when a number is too big for its box, and pick a bigger one.8 min

Stage 2Making decisions

  1. Two ways to goRun some lines only when a condition is true, and other lines when it is not.8 min
  2. More than two casesChoose between several paths with a chain of questions.8 min
  3. And, or, notCombine several conditions into one answer.9 min
  4. Decisions inside decisionsPut a choice inside another choice, one question at a time.9 min

Stage 3Loops that count

  1. Doing it again and againRepeat some lines for every number in a range, keeping a running total.9 min
  2. Using the counterMultiply instead of add, and start the box at the right number.8 min
  3. Counting the ones that countCount only the numbers that pass a test, by putting an if inside a loop.9 min
  4. Jumps and countdownsMake a loop skip ahead by more than one, or count backwards.8 min

Stage 4Loops that wait

  1. Repeat untilKeep repeating while a condition stays true, even when you don't know how many passes it takes.8 min
  2. Stopping earlyLeave a loop the moment you have your answer.9 min
  3. When you can't predict the lengthFollow a rule until you reach the end, even though you can't tell how long it takes.9 min
  4. Taking a number apartLoop over the digits of a number, one at a time, from the right.9 min

Stage 5Functions

  1. A function you write yourselfGive a small job its own name, then use it as often as you like.9 min
  2. Answering earlyReturn from inside a loop the moment you know the answer.8 min
  3. Breaking a job into small jobsSplit a big task into helper functions that each answer one question.10 min
  4. Names stay insideKnow that each function has its own boxes, and that numbers are copied when you pass them in.9 min

Stage 6Text

  1. Letters by positionPick letters out of a word by their position, and join pieces together.9 min
  2. Visiting every letterLoop over a string and count the letters that pass a test.8 min
  3. Building new textMake a new string one piece at a time, with separators in the right places.9 min
  4. Comparing neighboursCompare each letter with the one before it, and stop at the first surprise.9 min

Stage 7Lists

  1. A row of boxesKeep many values under one name, and pick one out by its position.9 min
  2. Visiting every itemLoop over a list and count the items that pass a test.8 min
  3. Looking for one itemSearch a list, return where you found it, and say so clearly when it isn't there.9 min
  4. Making a new listBuild a new list by adding the items you want, one at a time.9 min

Stage 8Loops inside loops

  1. A loop inside a loopMake every item meet every other item, with a loop inside a loop.10 min
  2. Rows, then columnsBuild a pattern of rows, where the inner loop writes the characters of one row.9 min
  3. A grid of numbersRead a table of numbers, row by row, with a loop inside a loop.10 min
  4. Walking the gridVisit a grid by positions, and choose whether to go along the rows or down the columns.10 min

Stage 9Mastery

  1. Fizz and buzzCount up, and say a word instead of the number when a rule fits.12 min
  2. The runner-upFind the second biggest different value in a list, in one pass.12 min
  3. A row of Pascal's triangleBuild one row of a number triangle from the row above it.12 min
  4. Roman numeralsWrite a number the way the Romans did, by taking the biggest piece away again and again.14 min

There’s more after this

These are the opening stages of Programming basics. The full path climbs on to harder problems and a mastery test. Create a free account and we’ll keep your place.

Start the full path free