CODING
ADVENTURE
0 / 12 completed

CASE 07 / CHAPTER 6

Read the radio-station note

Modules and Base64

IN THE STORY

Inside the copied archive, Adrian finds a text-friendly representation of a note. All required data is included below.

The idea

import makes a library available. Base64 represents bytes using text characters; it does not keep them secret. The library returns bytes, so decode("utf-8") turns them into text. validate=True asks the helper to reject invalid Base64 characters.

Your mission

Decode the value held in encoded and display its text.

Replace ____ with the missing expression, then choose Run code. Match the expected output before trying your own changes.

Before you run it

Is a message private simply because you cannot read its encoded form at a glance?

A little help?

Hint 1: a nudge

Keep the variable encoded and the supplied validation setting.

Hint 2: a closer look

Call base64.b64decode(encoded, validate=True).

How the answer works

The decoded text is Meet Leonard. Both the encoded input and its expected result are provided, so you can check each step.

This replaces the code in the editor. Save your version first if you want to keep it.

Make it yours

Encode a short invented message with base64.b64encode(b"Hello"). Decode it again.

radio_note.pyPYTHON 3

Four spaces indent a block. Ctrl / ⌘ + Enter runs your code. Tab moves to the next control.

OUTPUTPython loads when you run
Your program's output will appear here.

Take a guess. Try a line. See what happens.

Expected output

Meet Leonard.

Code runs on your device. The first run downloads the Python engine (about 10 MB); later runs use the browser cache. Stop ends a run without losing your code.