Skip to content

Python Basics

Python is one of the easiest programming languages to learn, because it reads a lot like English. MicroPython is a slimmed-down version that runs on microcontrollers. Almost everything you learn here also works in "full" Python on a computer.

This section covers just the ideas you'll use in the lessons and projects:

  1. Variables & Types: storing numbers, text and true/false values.
  2. Lists & Dictionaries: storing collections of things.
  3. If, For & While: making decisions and repeating things.
  4. Functions: packaging code up so you can reuse it.

Try everything as you read

Every example can be typed into Thonny's Shell (the >>> prompt) or pasted into the editor and run. The fastest way to learn is to change the examples and see what happens. You can't break anything.

Lines starting with # are comments

Python ignores everything after a # on a line. Comments are notes for humans, and you don't need to type them in.

Already know some Python? Skip ahead to Components. You can always come back.