There are two different versions of Python you can use to code the BBC micro:bit:
- MicroPython - used in the micro:bit Python Editor, and other editors.
- Microsoft MakeCode Python - used in the MakeCode editor when you switch from Blocks to JavaScript and then select ‘Python’ from the drop-down arrow.
This can be confusing, so this article explains the difference and helps you choose which one is right for you.
Comparison
Let’s compare the Emotion badge project in each version of Python.
MicroPython
from microbit import *
while True:
if button_a.is_pressed():
display.show(Image.HAPPY)
if button_b.is_pressed():
display.show(Image.SAD)(Open in the micro:bit Python Editor.)
Microsoft MakeCode Python
def on_button_pressed_a():
basic.show_icon(IconNames.HAPPY)
input.on_button_pressed(Button.A, on_button_pressed_a)
def on_button_pressed_b():
basic.show_icon(IconNames.SAD)
input.on_button_pressed(Button.B, on_button_pressed_b)(Open in the MakeCode editor.)
The MicroPython version looks like the kind of Python you may be used to teaching in coding lessons.
- It uses an import statement to add functionality to Python, in this case to use the features of the micro:bit device. Imports are the standard way of adding functionality when coding in Python.
- MicroPython is not based on ‘events’, so it uses a while True: loop to keep testing if a button has been pressed.
In Microsoft MakeCode Python, the code looks less like the kind of Python commonly taught in schools.
- A library defining an interface that matches the blocks (to make it possible to switch seamlessly between blocks, JavaScript, and Python) has already been imported for you.
- MakeCode is based on events, such as on_button_pressed_a(): It programs the micro:bit as a reactive system.
Choosing which to use
- Microsoft MakeCode Python (and JavaScript) are good options if you are mainly using blocks for coding, but want occasionally to switch between blocks and text.
- MicroPython is better if you are teaching coding in Python. It is used by the official Micro:bit Educational Foundation Python editor, as well as other Python editors which support the micro:bit.
The micro:bit Python Editor

The micro:bit Python Editor is designed for the classroom and to help learners transition from blocks to text-based coding. Find out more about its features to support creativity and debugging in our User guide.
More about MicroPython
The Micro:bit Educational Foundation is committed to ongoing support of MicroPython on the BBC micro:bit, both for the micro:bit Python Editor at python.microbit.org and to support the diversity of other MicroPython editors that work with the micro:bit.
MicroPython has its own runtime on the micro:bit. It is a tiny Python interpreter that runs on the board (at a low level). It is a popular programming language because it is optimised to work on microcontrollers like the micro:bit. It is almost a full re-implementation of Python 3 but is designed to be able to run in a low memory and low power environment.
The micro:bit Python Editor is the perfect environment for building programs to run on your micro:bit, as you can easily access the REPL (Read, Evaluate, Print, Loop) and also connect directly to your micro:bit to flash programs via USB.
You can access MicroPython API documentation here: https://microbit-micropython.readthedocs.io/en/latest/. You will also find API documentation inside the micro:bit Python Editor, along with a reference guide of code snippets you can drag into your programs.