User Avatar
Uncategorized

Dictionary Primer

Lifetime
All levels
4 lessons
0 quizzes
1 student

What it’s about

This short tutorial introduces dictionaries, a way of organizing data as a set of key-value pairs.  Shopping and ingredient lists are examples of key-value pairs.  Here’s how one might look in a MicroPython dictionary:

shopping = { ’bananas’: 3, ’bread’: 1, ’peanut butter’: 1,  ’soda’: 6 }

Another example could be a Cybersecurity app where a controller micro:bit sends radio navigation commands to a micro:bit in a cyber:bot.  Both micro:bit modules will run scripts that use dictionaries.  So, take some time to get familiar with dictionaries now, because you’ll use them a lot later.

Before you start

You will need:

  • A micro:bit module (on or off a cyber:bot)
  • A USB A to MicroB cable
  • A computer with Internet access to python.microbit.org

Complete this tutorial first:

After you finish

You will understand how dictionaries use key-value pairs for storing and managing data. This will help you better understand and work with the MicroPython code examples in the Cybersecurity: Radio Data and later tutorials.

After this, you will also be ready to move on to the next tutorials (with more coming soon!):