Skip to content

Python emotion badge

Lesson 3 of 6

Python

9-12 yrs, 11-14 yrs

Start learning about inputs and outputs using buttons and icons on the display.

Key learning:

  • I understand that inputs and outputs involve the flow of data in and out of computers. 
  • I can apply this knowledge to the micro:bit’s button inputs and display output.
  • I can write instructions in Python to make something happen when a button is pressed on the micro:bit.

Computer systems:

Input/output

Programming:

Text-based programming

Lesson plan preview

Slides preview

Student handouts

Completed lesson code

This provides an example of the code created during this lesson.

1from microbit import *
2
3while True:
4    if button_a.is_pressed():
5        display.show(Image.HAPPY)
6    if button_b.is_pressed():
7        display.show(Image.SAD)

You may also be interested in

Introduces our Python Editor that helps learners to write code for the BBC micro:bit. We will highlight all the great features in our editor that support you and your learners to code the micro:bit successfully using Python.

A sequence of lessons that provide a pathway through six projects, ideal for getting started with the micro:bit. Students develop their use of some core computing concepts by coding and making practical projects including step counters, nightlights, and games.

Seven lessons introducing AI in general and unpacking what students already know about sorting data, before getting hands-on, creating, testing and improving their own machine learning models to be used as new inputs in code on the micro:bit.