Learn why functions exist, how modules split code across files, and how virtual environments keep your projects clean.
Day 21 of 80
Do this first — it takes 2 minutes and you'll understand it better after watching the third video. Open your terminal in the prompt-vault/ folder and run:
$ python -m venv venv
# Creates a venv/ folder — your isolated Python sandbox
$ venv\Scripts\activate
(venv) $
# You're now inside the environment. Notice (venv) in the prompt.
(venv) $ pip install anthropic python-dotenv
Successfully installed anthropic-... python-dotenv-...
You created a private Python sandbox. The anthropic and python-dotenv packages are now installed only inside this project — not globally on your machine. When Corey explains why this matters, you'll have already experienced it firsthand.
All three are from Corey Schafer's Python Beginner series — some of the clearest Python teaching on the internet. Watch them in order.
| # | Video | Length | Focus |
|---|---|---|---|
| 1 | Functions | ~20 min | Parameters, return values, scope |
| 2 | Import Modules and Exploring the Standard Library | ~25 min | Splitting code across files, the standard library |
| 3 | Virtual Environments Tutorial | ~15 min | Keeping project libraries separate |
Back in Week 3, you wrote load_prompts() and save_prompts(). You used them without fully understanding why they were written as functions. Today Corey explains the WHY behind every function you've already used:
def save_prompts(prompts):)save_prompts(my_list))load_prompts() doesn't accidentally overwrite a variable outside itWhen you hear these explained clearly, you'll feel that satisfying click of "oh — that's what I've been doing."
Parameters are the variable names defined in the function signature. Arguments are the values you pass when calling it. Corey explains this clearly — it's a distinction worth locking in now.
A function can give something back to the code that called it. Without return, the function does its work and disappears. With return, it hands you a value you can store in a variable or pass somewhere else. Your load_prompts() uses this — it returns the list of prompts.
Variables created inside a function only exist inside that function. This is a feature, not a limitation — it means your functions can't accidentally break each other's data. Corey demonstrates this with examples that make the rule stick.
When you write import json, you're using Python's module system. Corey shows you that your own files work exactly the same way — you can split your code into multiple .py files and import functions between them. This is what Day 23's build project uses.
Each Python project can have its own private set of installed packages. A virtual environment is that private sandbox. Without it, installing a new package for one project can break a different project that needs an older version. By the end of Week 5, every project you create will start with python -m venv venv.
Don't just let them run in the background. Get the most out of 60 minutes:
return? What if you use a variable name that exists outside the function?As you watch, keep your Week 3 and Week 4 code open in another window. Notice:
import json at the top of your file is the module system Corey explains in video 2venv folder you created above is exactly what video 3 is aboutprompt-vault/ folder and anthropic + python-dotenv are installedreturn matters and what happens without itTomorrow you put today's theory into practice. You'll read Cursor's Python guide (15 minutes), then run four Jupyter notebook cells exploring default parameters, multiple return values, and how to organize imports. All the examples use your Prompt Vault data — video shots, platforms, filenames.