MicroCode Coach
S
Sarah
Stage 1 of 9

🎯 The Challenge

You need your marketing script to output the exact words: Sales Data Loaded. However, the code below is currently crashing the system. Your goal is to find what's wrong.

🧠 Concept: Speaking to the Computer

Computers are incredibly literal. When you type letters into a coding environment, the computer assumes you are referencing a Variable (a data container, which we'll cover next). It tries to look up a container named "Sales Data Loaded" and crashes because it doesn't exist.

If you just want the computer to treat your words as normal English text, you must wrap the words in quotation marks " ".

In the coding world, normal text wrapped in quotes is called a String (think of it like a string of letter beads). The print() command is like a megaphone — it shouts whatever you put inside its brackets. But the megaphone only accepts properly formatted Strings!

🛠️ Try it out

Based on what you just read, click the exact part of the code below that is causing the error.

marketing_script.py
print ( Sales Data Loaded )
Stage 2 of 9

🎯 The Challenge

You have a marketing budget of £5000. We need to store this number in the system so we can use it later without retyping it. Choose the correct way to store it below.

🧠 Concept: The Variable "Jar"

In Excel, you reference cells like B2 or C4. In programming, you can name your own cells! These custom cells are called Variables.

To create a variable, you need three things: a label, an equals sign, and the data. But there is a massive "gotcha" for beginners:

The = sign in coding does NOT mean "mathematically equal to".
Instead, it acts as a left-pointing arrow (). It tells the computer: "Take the data on the right, and put it into the label on the left."

Think of it like sticking a label on a jar. The jar's label must always go on the left, and the contents going into the jar go on the right.

🛠️ Try it out

Select the option that correctly stores the number 5000 inside a variable named marketing_budget.

marketing_budget = 5000
5000 = marketing_budget
Stage 3 of 9

🎯 The Challenge

Your new campaign is called Summer Sale. You need to create a variable to store this campaign name. Pick the correct code to make this happen.

🧠 Concept: Combining Your Knowledge

Let's combine what we learned in Stage 1 and Stage 2!

We know that variables need a label on the left and data on the right. We ALSO know that computers are literal, and if the data is English text, it must be protected by quotation marks so the computer knows it's a String.

If you forget the quotes, the computer will look at the words "Summer Sale" and think you are trying to stuff two other jars inside your new jar, causing a crash!

🛠️ Try it out

Which line of code correctly stores the text string into the variable?

campaign_name = Summer Sale
campaign_name = "Summer Sale"
Stage 4 of 9

🎯 The Challenge

You don't just have one marketing channel, you have three: Email, SEO, and Social. We need to store all of them in a single variable. Find the bug in the code below.

🧠 Concept: Grouping Data into Lists

A standard variable is like a single jar. But what if you have a whole collection of items? You need a bigger container with compartments. In programming, this is called a List.

To tell the computer you are making a list, you must wrap all your items in Square Brackets [ ] and separate each item with a comma.

Square brackets act as the outer boundaries of your list. Without them, the computer just sees a chaotic jumble of words floating around and will throw an error.

🛠️ Try it out

The code below is trying to make a list of your channels, but it's missing the crucial outer boundaries. Click the area where the boundaries should go.

channels.py
channels = "Email", "SEO", "Social" (Missing Brackets)
Stage 5 of 9

🎯 The Challenge

Your channels list is built — but now you need to print each channel name on its own line: "Email", then "SEO", then "Social". Writing three separate print() statements works for three items, but what about when you have 1,000 customer emails to process? You need a way to repeat an action automatically for every item in a collection.

🧠 Concept: The For Loop

A For Loop is the computer's way of saying "do this same thing for every item in my list." It's the tireless assistant who reads through every row of your spreadsheet so you don't have to.

The structure has two halves connected by the word in:
for [TEMPORARY LABEL] in [LIST]:

The temporary label on the left is a brand-new variable that you invent on the spot. On each pass through the loop, this label gets re-assigned to hold the current item. So if your list is ["Email", "SEO", "Social"], the label becomes "Email" on pass 1, "SEO" on pass 2, "Social" on pass 3 — automatically.

Order is everything: the temporary label always sits to the left of in, and the actual list (the source of items) sits to the right. Swap them, and the computer can't tell which one to iterate over.

🛠️ Try it out

Which line correctly loops through every item in the existing channels list, storing each one in a fresh temporary variable called channel?

for channel in channels:
for channels in channel:
Stage 6 of 9

🎯 The Challenge

Your script should react to the budget: when marketing_budget equals 5000, it should flag the campaign as "Premium." The code below tries to do this — but instead of checking the budget, it's about to silently overwrite it. Find the bug.

🧠 Concept: Asking Questions with If

Computers can make decisions using if statements. The structure is if [QUESTION]: — and any indented code below it only runs when the answer is "yes."

But here's the trap that catches every beginner. Remember Stage 2: a single equals sign = is the assignment arrow. It changes data. It does NOT ask a question.

To compare two things — to ask "are these the same?" — you need double equals: ==. Think of it as stacking two equals signs because you're checking equality from both directions.

If you accidentally write = inside an if, the computer doesn't crash — it silently overwrites your variable with a new value. That's a bug that can hide for hours, because nothing visibly breaks.

🛠️ Try it out

The line below is supposed to check whether the budget equals 5000, but as written it would assign instead. Click the symbol that's wrong.

budget_check.py
if marketing_budget = 5000 :
Stage 7 of 9

🎯 The Challenge

You're typing the same three lines over and over to greet new customers: load the name, format the greeting, print it. You need a way to bundle these steps into one reusable command — a custom verb you can call by name whenever a new customer signs up.

🧠 Concept: Building Your Own Commands

So far, you've used commands the language gave you, like print(). A function lets you create your own reusable command — a saved recipe you can call any time you need it.

To create a function in Python, three pieces go in this exact order:

1. The keyword def (short for "define") — the trigger word announcing "I'm making a new command."
2. The name you want for your command (e.g. greet_customer).
3. Parentheses () listing any data the command needs, followed by a colon :.

The data inside the parentheses is called a parameter — a temporary variable that gets filled in fresh each time the function is called. It's like a blank space in a Mad Libs template, waiting for someone to drop in a real value.

Watch out: parameters live inside the parentheses, never after an equals sign. The = would turn this into an assignment, which is a completely different operation.

🛠️ Try it out

Which option correctly defines a new function called greet_customer that accepts a piece of data named name?

def greet_customer(name):
function greet_customer = name:
Stage 8 of 9

🎯 The Challenge

Customer Sarah has a name, an email, and a budget. You could store these in three separate variables — but then they'd float around with no obvious connection between them. You need to bundle them into a single labelled record. The code below is almost right, but one of the connectors between a label and its value has been replaced with the wrong symbol. Find it.

🧠 Concept: Labelled Data with Dictionaries

A List (Stage 4) finds items by position — item #1, item #2. That's fine for an ordered queue of channels, but useless when you want to look up "Sarah's email" by name.

A Dictionary stores data as key-value pairs, exactly like a real-world dictionary where you look up a word (the key) and find its definition (the value). Each pair is connected by a colon : — and that colon is the bridge that says "this label points to this data."

The whole dictionary is wrapped in curly braces { } (not square brackets — those belong to lists), and the pairs are separated by commas.

Replace the colon with anything else — a dash, an arrow, an equals sign — and the computer can no longer tell which label belongs to which value. The dictionary fails to build, and the whole record falls apart.

🛠️ Try it out

The dictionary below tries to build Sarah's customer record, but one connector between a key and its value is wrong. Click the broken connector.

customer.py
customer = { "name" : "Sarah", "email" - "sarah@ex.com", "budget" : 5000 }
🏆

You Did It, Sarah!

You've mastered Strings, Variables, Assignment, Lists, For Loops, If/Else logic, Functions, and Dictionaries. That's the full foundational toolkit — you now have everything you need to start automating real spreadsheet workflows!