Strings & Characters Primer

What it’s about

This primer tutorial covers some of the Python basics of strings and characters. These skills will help build your cybersecurity skills and serve you well in competitions with the cyber:bot.

Strings are sequences of characters.  For example, “ABC” is a string of characters.  Computer software, apps, and Internet communication all depend heavily on strings.  For example, much of the communication between browsers and servers over the Internet contains strings.  These strings might contain Internet searches, GPS coordinates, text messages and more.  Many of the messages you see on web pages and in apps also started as strings.  

The Cybersecurity tutorials also rely heavily on strings to exchange radio messages between cyber:bot robots and other micro:bit modules.  These strings may have packet data that could contain a code for a particular cyber:bot, navigation instructions, and even sensor values.  They can be encrypted by the center and decrypted by the receiver to prevent misuse if intercepted by another team.  So, later, you’ll use a micro:bit to send and another to receiver, but here, we’ll focus on the string and character basics using scripts that a single micro:bit will run.

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:
    • Access to
      -- or --
    • Mu editor installed
  • Note that is used in this tutorial's screencaptures.

Complete this tutorial first:

After you finish

You have skills with character and string basics you’ll use in upcoming tutorials for packetizing, parsing, encrypting, decrypting, and evaluating: 

  • Create and access strings, substrings, and characters
  • Manipulate string information to create modified strings from existing strings and characters
  • Check strings for certain information
  • Convert strings to other data types, process the data, and convert back to stings
  • Embed Python expressions and even executable statements in strings

After this, you will also be ready to move on to the next tutorials: