CodeBlocks

Learn to code by writing code that plays the drums. Every challenge shows a beat — write the Python that plays it. No experience needed.

for b in range(1, 9):
    hihat(b)
    if b % 2 == 0:
        snare(b)

Start with lesson 1 — it takes one line of code.

Beat LabFree coding with the whole kit: ride, rimshot, toms and more.→StudioBuild real music apps: HTML, CSS, JavaScript and your own Python server.→

Unit 1: Your First Beats · Python

Start from zero: call your first function, then build up to loops, decisions and functions of your own — every line of code plays the drums.

  1. 1Hello, KickCalling a function0/4
  2. 2Build a GrooveSequencing commands0/4
  3. 3Inputs: Faster NotesFunction inputs (arguments)0/4
  4. 4VariablesStoring values in variables0/4
  5. 5ListsLists0/4
  6. 6Loopsfor loops and range()0/4
  7. 7Loop Through a ListLooping over a list0/4
  8. 8Decisions: if and elseif / else and the % operator0/4
  9. 9Make Your Own CommandsDefining functions0/4
  10. 10Functions with InputsFunction parameters0/4

Unit 2: Patterns & Logic · Python

Smarter decisions (elif, and/or, in), counters, loops inside loops, functions that answer back and drum patterns written as text — ending with a drum machine you build yourself.

  1. 1More Choices: elifif / elif / else0/4
  2. 2and, or, notCombining conditions0/4
  3. 3Is It in the List?Checking membership with in0/4
  4. 4CountersChanging values with += and -=0/4
  5. 5Loops Inside LoopsNested loops0/4
  6. 6while LoopsLooping while something is true0/4
  7. 7Functions That Answerreturn values0/4
  8. 8List PositionsIndexing lists and len()0/4
  9. 9Drum Patterns as TextStrings0/4
  10. 10Build a Drum MachinePutting it all together0/4

Unit 3: Lists Level Up · Python

Build lists as you go, slice them, sort them, pop and insert — and walk two lists at once with zip() and enumerate().

  1. 1Building ListsStarting empty and appending0/4
  2. 2pop, insert, removeChanging a list0/4
  3. 3SlicingTaking part of a list0/4
  4. 4sum, min, max, lenBuilt-ins that read a whole list0/4
  5. 5Sortingsorted(), .sort() and .reverse()0/4
  6. 6zip and enumerateWalking lists together0/4
  7. 7Counting and Finding.count(), .index() and in0/4
  8. 8Combining Lists+, *, .extend() and .copy()0/4
  9. 9Choosing Valuesx if condition else y0/4
  10. 10Project: The Beat QueueLists of lists and list methods together0/4

Unit 4: Text Tricks · Python

Count letters, change case, split and join, build f-strings and slice text — then turn letters, words and whole sentences into beats.

  1. 1Letters Countlen(), .count() and .find() on text0/4
  2. 2Big and Small Letters.upper(), .lower() and .strip()0/4
  3. 3Split into Words.split()0/4
  4. 4Join and Replace.join(), .replace() and * on text0/4
  5. 5f-stringsPutting values inside text0/4
  6. 6Letters to DrumsA letter for every drum0/4
  7. 7Slicing TextSlices and [::-1] on text0/4
  8. 8Checking Text.startswith(), .endswith(), .isdigit() and in0/4
  9. 9Building Patterns from TextGrowing text in a loop0/4
  10. 10Project: Word BeatsTurning any word into a beat0/4

Unit 5: Grids · Python

Lists inside lists: rows and columns, loops inside loops, grids built from text — the same layout as a real drum machine.

  1. 1Rows and ColumnsLists of lists0/4
  2. 2Loop the GridNested loops over rows and columns0/4
  3. 3Change a Cellgrid[r][c] = value0/4
  4. 4Build a GridMaking grids with loops0/4
  5. 5Grids from TextA list of pattern strings0/4
  6. 6Row and Column MathAdding up rows and columns0/4
  7. 7Flip and Shift RowsReversing, shifting and inverting a row0/4
  8. 8Thinking in ColumnsReading a grid down, not across0/4
  9. 9Grid PatternsFilling grids with (row + col) % n0/4
  10. 10Project: Your Grid MachineA full drum-machine grid0/4

Unit 6: Dictionaries · Python

Keys and values: name every part of a song, look things up safely, count with dictionaries, and build Drum Machine 2.0 with mute and solo.

  1. 1Key and ValueDictionaries0/4
  2. 2Loop Through a DictionaryLooping over keys and .items()0/4
  3. 3Look It Up Safelyin and .get()0/4
  4. 4A Dictionary of PatternsPatterns stored by drum name0/4
  5. 5Counting with DictionariesTallying with counts[x] = counts.get(x, 0) + 10/4
  6. 6Settings and NestingDictionaries of settings, dictionaries inside dictionaries0/4
  7. 7Beats as KeysNumber keys0/4
  8. 8Lists of DictionariesA list where every item is a dictionary0/4
  9. 9Dictionary Trickslen, sorted keys, merging and swapping0/4
  10. 10Project: Drum Machine 2.0A dictionary-driven drum machine0/4

Unit 7: Debug It! · Python

Every programmer's superpower: read error messages, spot typos, fix off-by-ones and never-ending loops, and hunt down bugs that don't even cause an error.

  1. 1TyposReading an error message0/4
  2. 2Colons and IndentsBlock structure bugs0/4
  3. 3Off by OneCounting mistakes0/4
  4. 4= vs ==Storing vs comparing0/4
  5. 5Loops That Never StopInfinite loops0/4
  6. 6Wrong OrderOrder of lines0/4
  7. 7Text and Number Mix-ups"3" is not 30/4
  8. 8Function Bugsprint vs return, unused inputs, forgotten calls0/4
  9. 9List BugsPositions, pop and sort gotchas0/4
  10. 10Mystery BugsBugs that don't cause errors0/4

Unit 8: Functions Level Up · Python

Default and keyword inputs, functions that return lists, functions passed to functions, recursion and scope — ending with a groove generator.

  1. 1Default InputsInputs with default values0/4
  2. 2Keyword InputsCalling with input names0/4
  3. 3Returning ListsFunctions that return lists (and two values)0/4
  4. 4Functions and FunctionsCalling and passing functions0/4
  5. 5RecursionFunctions that call themselves0/4
  6. 6ScopeWhere variables live0/4
  7. 7Functions That DecideReturning choices0/4
  8. 8A Library of GroovesFunctions stored in dictionaries and lists0/4
  9. 9Parameter PowerFlexible building blocks0/4
  10. 10Project: Groove GeneratorA function that builds whole grooves0/4

Unit 9: Algorithms & Rhythm · Python

Step-by-step recipes: running totals, searching, sorting by hand, Fibonacci and primes, Euclidean rhythms from around the world, and repeatable randomness.

  1. 1Running TotalsAccumulators0/4
  2. 2SearchingLinear search and break0/4
  3. 3Finding the BiggestMax and min by hand0/4
  4. 4FilteringKeeping what matches0/4
  5. 5MappingChanging every item0/4
  6. 6Sorting by HandSwaps and bubble sort0/4
  7. 7Number SequencesFibonacci, primes and squares0/4
  8. 8Euclidean RhythmsSpreading hits evenly0/4
  9. 9Repeatable RandomPseudo-random number generators0/4
  10. 10Project: Algorithm MixerCombining algorithms0/4

Unit 10: Final Projects · Python

Ten projects that use everything: name beats, number beats, odd time signatures, your own pattern language, a mixing desk, a remixer — and your signature groove.

  1. 1Project: Name BeatText → rhythm0/4
  2. 2Project: Number BeatDigits → beats0/4
  3. 3Project: Odd TimeGrooves in 5, 6 and 70/4
  4. 4Project: Pattern ParserReading your own mini-language0/4
  5. 5Project: Mixing DeskTracks, mute and solo0/4
  6. 6Project: Call and ResponseAnswering a rhythm0/4
  7. 7Project: RemixerTransforming a whole groove0/4
  8. 8Project: Fill GeneratorFills from rules0/4
  9. 9Project: Beat DecompressorRun-length encoding0/4
  10. 10Capstone: Signature GrooveEverything together0/4

Unit 11: Programs, Not Scripts · Python

Classes and objects, state that changes, events and handlers, a playhead that keeps time, saving data, and a Beat Server — everything you need for CodeBlocks Studio.

  1. 1Your First Classclass, __init__ and self0/4
  2. 2MethodsFunctions that belong to an object0/4
  3. 3Lots of ObjectsLists of objects0/4
  4. 4Objects Working TogetherAn object that holds objects0/4
  5. 5Changing StateObjects that remember0/4
  6. 6Events and HandlersCode that waits for something to happen0/4
  7. 7The PlayheadState over time0/4
  8. 8Data In, Data OutSaving objects as dictionaries0/4
  9. 9Requests and ResponsesHow a server thinks0/4
  10. 10Project: Beat ServerA backend for a music app0/4

Badges · 0 of 8

  • 👋Hello, WorldSolve your first challenge.
  • 🔁First LoopFinish every challenge in one lesson.
  • 🎧Bedroom ProducerSolve 10 challenges.
  • 🐛Bug SquasherFinish 3 lessons.
  • 🎛️Beat EngineerSolve 20 challenges.
  • 🎙️Studio SessionFinish 5 lessons.
  • 🥁Code DrummerSolve 30 challenges.
  • 🏆Full Stack DrummerFinish every lesson available.