← learn.jakobbeck.com
MøllerBeck · Phase 1 Reference
Python Primer
Keep this open during every Phase 1 session. Every concept you need, with plain-English explanations and real examples. Navigate by topic using the tabs below.
▶ Phase 1 — Weeks 1–6
Before you write a single line of code, you need three things installed. This tab walks you through each one, in the right order, with exact commands to type. Every command goes into the Terminal. If anything doesn't work exactly as described — stop and ask before continuing.
Step 1 of 3
Open the Terminal
The text window where you'll run all commands
The Terminal is an app already on your Mac. You don't need to install it.

To open it: Press Cmd + Space to open Spotlight. Type Terminal. Press Enter.

A black or white window opens with a line ending in %. That % is the prompt — it means Terminal is waiting for a command. You type a command, press Enter, it runs.
The golden rule of Terminal: If you type a command and nothing happens (the cursor just returns to the prompt), it worked silently. If you see red text or the word "error", something went wrong. Copy the error and bring it to me.
How you know it worked
Terminal window is open
You can see a prompt ending in %
Step 2 of 3
Check Python is installed
macOS may already have it — check before installing
Python might already be on your Mac. Type this command exactly and press Enter:
Type in Terminal
python3 --version
You should see something like Python 3.11.4 (the exact numbers may differ — any version starting with 3 is fine).

If you see a version number: Python is installed. Move to Step 3.

If you see "command not found": Python is not installed. Install Homebrew first (a package manager that makes installing things easy), then use it to install Python. Bring this to me and I'll walk you through it.
How you know it worked
Terminal prints Python 3.x.x
Step 3 of 3
Install VS Code
The editor where you'll write all your code
VS Code is a free code editor made by Microsoft. You'll write every script in here.

Steps:
1. Open Safari. Go to code.visualstudio.com
2. Click the large blue "Download for Mac" button
3. Open the downloaded .zip file — it creates a VS Code app
4. Drag the VS Code app into your Applications folder
5. Open VS Code from Applications
Once open, install the Python extension:
Click the icon on the left sidebar that looks like four squares (Extensions). Search for "Python". Click Install on the first result (published by Microsoft). This tells VS Code how to work with Python files.
How you know it worked
VS Code opens without errors
Python extension shows as installed in Extensions sidebar
Create a new file (Cmd + N), save it as test.py — the filename turns green/blue in the sidebar
Step 3b — Run your first script
Hello World
The first thing every programmer writes
By convention, the first script anyone writes prints "Hello, World". It's a complete end-to-end test: file created, code written, Python run from Terminal, output seen.
In VS Code — create hello.py and type this exactly
print("Hello, World")
Save the file (Cmd + S). Now open the Terminal in VS Code by pressing Ctrl + ` (the backtick key, top-left of keyboard). Navigate to where you saved the file — if you saved it to the Desktop:
In Terminal
cd ~/Desktop
python3 hello.py
You should see Hello, World printed in the Terminal.
Session 1 complete when
Python installed and confirmed with python3 --version
VS Code installed with Python extension
hello.py runs and prints Hello, World
Weeks 1–2: The building blocks every Python script uses. Variables, text, numbers, comparisons, and loops. By the end of Week 2 you should be able to write a script that stores data and prints formatted output — without help.
Week 1 · Day 1–2
Variables
Naming and storing values
A variable is a label attached to a value. You create it with an equals sign: the name on the left, the value on the right.
Variables — type this into a .py file and run it
# The # symbol starts a comment — Python ignores it
# Comments are notes to yourself (and me)

company_name = "Vestas Wind Systems"   # a string (text)
employee_count = 400                    # an integer (whole number)
is_public = True                        # a boolean (True or False)

print(company_name)      # prints: Vestas Wind Systems
print(employee_count)    # prints: 400
print(is_public)         # prints: True
String
Text wrapped in quotes. "Like this" or 'like this'.
Integer
A whole number. 42, -7, 1000. No quotes, no decimal point.
Boolean
True or False — exactly these words, capital first letter. Used for yes/no conditions.
print()
A built-in function that displays output in the Terminal. Your main debugging tool early on.
Naming convention: Use lowercase letters and underscores for variable names. company_name ✓   CompanyName — works but not Python style   company name ✗ spaces not allowed.
Week 1 · Day 3
f-strings
Putting variables inside text — you'll use this constantly
An f-string lets you embed variable values directly inside a string. Put an f before the opening quote, then wrap variable names in {curly braces}.
f-strings
name = "Vestas"
employees = 400

# Without f-string — awkward
print("Company: " + name + ", Size: " + str(employees))

# With f-string — clean
print(f"Company: {name}, Size: {employees}")
# Both print: Company: Vestas, Size: 400
Why this matters for your project
Your Phase 1 project produces formatted briefing summaries. f-strings are how you'll build each line: f"Client: {client_name} | Industry: {industry} | Size: {employees} FTE" — pulling each value from your CSV data into a readable line.
Week 1 · Day 4–5
If / elif / else
Making decisions — run different code depending on conditions
Conditionals — indentation matters
employees = 650

if employees > 500:
    print("Large company")     # runs if True
elif employees > 200:
    print("Mid-size company")  # runs if first was False
else:
    print("Smaller company")   # runs if all above False

# Prints: Large company
Indentation is not optional. The four spaces before print tell Python "this line is inside the if block". Get the spacing wrong and Python will give you an IndentationError. VS Code will do this for you automatically — just press Tab after a colon.
Week 2 · Day 1–3
Lists and loops
Collections of items, and running the same code for each one
Lists and for loops
# A list — square brackets, comma-separated
clients = ["Vestas", "Ørsted", "Grundfos"]

# A for loop — runs once for each item
for client in clients:
    print(f"Processing: {client}")

# Prints:
# Processing: Vestas
# Processing: Ørsted
# Processing: Grundfos

# Access a specific item by index (starts at 0)
print(clients[0])   # Vestas
print(clients[2])   # Grundfos
Why loops matter for MøllerBeck
Your briefing summariser will read a CSV with dozens of clients. Without a loop you'd write the same processing code for each client by hand. With a loop: write the code once, it runs for every client in the file automatically.
Week 2 · Weekend Exercise
Build a simple client lister
Write a script that stores 3 fictional clients as a list, then loops through them and prints a formatted line for each. This is the skeleton of your Phase 1 project.
1
Open VS Code. Create a new file: Cmd + N. Save it as clients.py on your Desktop.
2
Create a list called clients containing 3 strings (company names of your choice).
3
Write a for loop that prints each client using an f-string: f"Client: {client}"
4
Run it: open Terminal in VS Code (Ctrl + `), type python3 clients.py, press Enter.
5
Add a counter so it prints the number too: "Client 1: Vestas", "Client 2: Ørsted".
✓ Done when: all 3 clients print with numbers, no errors
Weeks 3–4: Functions and files. Functions let you package code so it can be reused. Files let your scripts read from and write to the disk — this is how your Phase 1 project reads a CSV of clients.
Week 3 · Day 1–3
Functions
Named blocks of code you define once and call many times
A function is a reusable recipe. You define it once with def, then call it by name whenever you need it.
Defining and calling a function
# Define the function — this does NOT run it yet
def format_client(name, industry, size):
    summary = f"{name} | {industry} | {size} employees"
    return summary

# Call the function — this runs it
result = format_client("Vestas", "Energy", 400)
print(result)
# Prints: Vestas | Energy | 400 employees

# Call it again with different data
result2 = format_client("Ørsted", "Renewable energy", 800)
print(result2)
def
The keyword that starts a function definition. Short for "define".
Parameters
The inputs a function expects — name, industry, size in the example above. Listed in parentheses after the function name.
return
Sends a value back out of the function. Without return, the function does its work but nothing comes back.
Call
Running a function by using its name with parentheses: format_client("Vestas", ...)
Week 3 · Day 4–5
Reading files
Opening a file from disk and reading its contents
Reading a text file
# open() accesses the file. "r" means read-only.
# The 'with' block ensures the file is closed when done.

with open("notes.txt", "r") as f:
    contents = f.read()

print(contents)   # prints the full file

# Reading line by line
with open("notes.txt", "r") as f:
    for line in f:
        print(line.strip())   # .strip() removes newlines
The file must exist and be in the right place. If your script is on the Desktop and you write open("notes.txt"), Python looks for notes.txt on the Desktop too. If it's somewhere else, you need the full path.
Week 4 · Day 1–3
Reading CSV files
The core skill for your Phase 1 project
CSV (Comma-Separated Values) is a plain text format for tabular data. A CSV of clients might look like: Name,Industry,Employees on line 1, then one client per line. Python's built-in csv module handles this for you.
Reading a CSV — this is the core of your Phase 1 project
import csv   # import the csv module (built in, no install needed)

with open("clients.csv", "r") as f:
    reader = csv.DictReader(f)   # reads each row as a dictionary
    for row in reader:
        name = row["Name"]
        industry = row["Industry"]
        employees = row["Employees"]
        print(f"{name}{industry}{employees} staff")
What DictReader does
DictReader reads the first line of the CSV as column headers, then treats every row as a dictionary — so instead of row[0] (which is confusing), you write row["Name"]. Much more readable.
Week 4 · Weekend Exercise
CSV reader + formatter
Create a CSV file with 3 fictional clients (columns: Name, Industry, Employees). Write a script that reads it and prints a formatted summary for each client using a function.
1
In VS Code, create clients.csv. First line: Name,Industry,Employees. Then 3 rows of data.
2
Create summariser.py in the same folder. Import csv.
3
Define a function format_summary(row) that takes a row dictionary and returns a formatted string.
4
Use DictReader to read the CSV. Call format_summary(row) for each row and print the result.
✓ Done when: script prints 3 formatted summaries from the CSV file, no errors
Weeks 5–6: Dictionaries, JSON, and calling an API. Dictionaries are the most important data structure for your goals — almost every API response is a dictionary. JSON is the format data travels in. The requests library lets your Python script talk to the internet.
Week 5 · Day 1–3
Dictionaries
Key-value pairs — the data structure everything else builds on
A dictionary stores data as named pairs: a key (the label) and a value (the data). Like a row in a spreadsheet, but in code.
Dictionaries
# Create a dictionary with curly braces
client = {
    "name": "Vestas Wind Systems",
    "industry": "Energy",
    "employees": 400,
    "is_public": True
}

# Access values by key
print(client["name"])       # Vestas Wind Systems
print(client["employees"])  # 400

# Add or update a value
client["country"] = "Denmark"

# A list of dictionaries — one per client
all_clients = [
    {"name": "Vestas", "employees": 400},
    {"name": "Ørsted", "employees": 800}
]

for c in all_clients:
    print(c["name"])
Week 5 · Day 4–5
JSON
How data travels between services — looks just like a Python dictionary
JSON (JavaScript Object Notation) is a text format for structured data. It looks almost identical to a Python dictionary. When you call an API, it sends back JSON. Python's json module converts between JSON text and Python dictionaries.
JSON — reading and writing
import json

# A Python dictionary
data = {"name": "Vestas", "employees": 400}

# Convert to JSON string (for sending/storing)
json_string = json.dumps(data)
print(json_string)  # {"name": "Vestas", "employees": 400}

# Convert JSON string back to Python dictionary
back_to_dict = json.loads(json_string)
print(back_to_dict["name"])  # Vestas
Week 6
Error handling
What to do when something goes wrong
Scripts fail. Files aren't where you expect. Networks are unavailable. try/except lets you handle these failures gracefully instead of crashing.
try / except
# Without error handling — crashes if file missing
with open("clients.csv") as f:
    data = f.read()

# With error handling — fails gracefully
try:
    with open("clients.csv") as f:
        data = f.read()
    print("File read successfully")
except FileNotFoundError:
    print("Error: clients.csv not found — check the file path")
The most important skill in Phase 1 is reading error messages. Python errors are precise and helpful — they tell you exactly what went wrong and where. The key is knowing how to read them.
Anatomy of an error
Read from the bottom up
Example error output in Terminal
Traceback (most recent call last):
  File "summariser.py", line 12, in <module>
    result = format_client(row)
  File "summariser.py", line 6, in format_client
    summary = f"{row["name"]} | {row["industry"]}"
KeyError: 'name'
Read it bottom up:

Line 1 from bottomKeyError: 'name' — this is the actual error. Python tried to access the key "name" in a dictionary and it wasn't there.

Line 2 from bottom — tells you which file and which line caused it: summariser.py, line 6. Go to that line in VS Code.

Above that — the call chain. Which function called which. Useful for complex scripts, less relevant early on.
When you get an error: copy the entire output (everything from "Traceback" to the last line) and paste it to me. I need the full text — just describing the error in words loses the key detail.
Common errors in Phase 1
You will see all of these — here's what they mean
IndentationError — the spaces before a line are wrong. VS Code shows this with a red underline. Check that you're using 4 spaces (or a Tab) consistently.
SyntaxError — Python can't understand the line. Usually a missing colon after if or def, or unmatched quote/bracket. VS Code underlines the problem in red.
NameError: name 'x' is not defined — you used a variable before creating it, or mistyped its name. Check spelling — Python is case-sensitive: Clientclient.
FileNotFoundError — Python can't find the file you're trying to open. Either the filename is wrong, it's in a different folder, or it doesn't exist yet.
KeyError: 'column_name' — you asked for a dictionary key that doesn't exist. Usually means a column name in your CSV doesn't match what you typed in the code. Check capitalisation and spelling exactly.
TypeError — you tried to do something with the wrong type of value. E.g. adding a string to a number: "employees: " + 400 fails because one is text, one is a number. Fix: "employees: " + str(400)
The Phase 1 project is the evaluation. Build this by the end of Week 6. It should be genuinely useful — something you'd actually run before a client meeting.
Client Briefing Summariser
What it does, what it teaches, how to build it
What it does: You have a CSV file with your clients — name, industry, employee count, key notes. You run the script. It prints a formatted text summary for each client — the kind of briefing note you'd read before a meeting.

What it proves: You can read real data from a file, process it with a function, format output, and run a complete script without errors. This is the evaluation threshold for Phase 2.
Phase 1 Project — build this over Weeks 5–6
Build the summariser step by step
Each step builds on the last. Don't move to the next until the current one works.
1
Create the CSV. In VS Code, create clients.csv. Columns: Name,Industry,Employees,Notes. Add 5 fictional (or real) clients.
2
Read the CSV. Create summariser.py. Use csv.DictReader to read the file and print each row's Name field. Get this working before adding anything else.
3
Write a format function. Define def format_briefing(row): that takes a row dictionary and returns a formatted multi-line string using f-strings.
4
Add a separator. Between each client's output, print a line of dashes — print("-" * 40) — so the output is readable.
5
Wrap in try/except. Handle the case where the CSV file is missing — print a clear error message instead of crashing.
6
Show it to someone. Run it. Read the output. If it's useful, you've passed Phase 1.
✓ Phase 1 complete when: script runs cleanly on a real CSV, produces readable output, you can explain every line of code