Programming from Scratch

Learn to code with Python, from your first variable to a real command-line tool.

10 projects, 250 hands-on levels, run in your browser.

Syllabus

  • Foundations: The absolute basics: store values in variables, do arithmetic, work with text, convert between types, and print results. By the end you build a small receipt calculator.
  • Control Flow: Teach your programs to decide and repeat. Booleans, if/elif/else, and/or/not, while and for loops, ending in a small board-game simulation.
  • Functions: Package code into named, reusable tools. Parameters, return values, scope, defaults and keyword arguments, building up to a small Mad Libs story generator.
  • Collections: Store and organise many values at once. Lists, dictionaries, sets and tuples, building up to a word-frequency report over real text.
  • Strings and Text: Take text apart and put it back together. Slicing, the string methods, formatting and parsing, building up to a working Caesar cipher that encrypts and decrypts.
  • Algorithmic Thinking: How computers solve problems efficiently. Recursion, linear and binary search, sorting from scratch, ending in a binary-search guessing-game solver.
  • Objects: Bundle data and behaviour together with classes. Attributes, methods, state, and inheritance, building up to a tiny RPG where two characters duel automatically.
  • Robust Programs: Write code that survives the real world. Catch and raise exceptions, read and write JSON, use the standard library, ending in an inventory loader that never crashes on bad data.
  • Working with Data: Process collections with style. Comprehensions, filtering and mapping, lambdas and sorting keys, generators, building up to a sales-data report.
  • Capstone: Build an App: Everything you have learned, in one project. Model tasks with dicts and lists, operate on them with functions and a class, parse text commands, and run them into a working command-line to-do app.

Key concepts

  • Assignment: Giving a name a value with = . The right side is evaluated first, then bound to the name on the left.
  • String: A piece of text, written in quotes. You can join, slice, and format strings.
  • Type conversion: Turning a value of one type into another, like int("42") to get the number 42 from text.
  • Variable: A name that points at a value, so you can store it and use it later. You create one with = .