Paths/AI Engineer/Python / Your First Python Script
Write Your First Script
Create the ~/ai-lab directory, write a tiny Python script and pin a dependency in a requirements.txt. In a real terminal you would run these files with the python command — here the focus is on the files themselves.
Validator
IDLE — checks run live as you type commands; submit when done
01Requirements
live checks- File ~/ai-lab/app.py exists and prints a greeting○
- File ~/ai-lab/requirements.txt exists and pins httpx○
02Walkthrough
7 steps- 01
Check where you are
pwd prints your working directory. You should be in /home/learner — the ~ character is shell shorthand for your home directory, so ~/ai-lab means /home/learner/ai-lab.
pwd - 02
Create the ai-lab directory
mkdir makes a new directory. Everything for this first project will live inside it.
mkdir ~/ai-lab - 03
Write the Python script
echo prints text and the > redirect writes it into a file, creating it if needed. This one line is a complete Python program: print outputs whatever is between the quotes when the script runs.
echo 'print("hello from ai-lab")' > ~/ai-lab/app.py - 04
Read the script back
cat prints a file's contents. You should see exactly the one line you just wrote.
cat ~/ai-lab/app.py - 05
Pin a dependency
Python projects list their external libraries in requirements.txt, one per line, usually pinned to an exact version with ==. httpx is the HTTP client most AI code uses to call model APIs — pinning 0.27.0 means a teammate installs exactly what you tested with.
echo httpx==0.27.0 > ~/ai-lab/requirements.txt - 06
List the project
ls lists the contents of a directory. Both app.py and requirements.txt should be there.
ls ~/ai-lab - 07
Submit for validation
The validator checks that app.py exists and contains the print line, and that requirements.txt exists and pins httpx==0.27.0.
03Stuck?
0 of 3 revealedTake a hint without losing the lab — each one points at the thing to look at, not at the answer.
04AI Tutor
guides, never solvesTell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?
04Notebook
saved locally in this browserlearner@lab — ubuntu:24.04
Session is disposable
↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list