On This Page
Prerequisites
This is a foundational chapter with no prerequisites beyond the course prerequisite.
- Operating system access: A working macOS, Linux, or Windows machine where you can install software and open a terminal application.
- Administrator privileges: Permission to install VS Code and its extensions on your machine. On macOS and Linux, this means access to sudo; on Windows, standard installer permissions.
- Internet connection: Required to download VS Code from code.visualstudio.com and install the Python extension from the VS Code marketplace.
Learning Goals
-
- Navigate directories using cd, ls, and pwd commandsUnderstand how to move through the filesystem hierarchy from the terminal, confirm your current location, and list directory contents to orient yourself within any project structure.
- Use pwd to print the absolute path of your working directory so you always know exactly where your terminal session is operating
- Use cd with relative paths like cd src/utils and absolute paths like cd /home/user/projects to move between directories efficiently
- Use ls with flags such as -l for detailed file metadata and -a for hidden files (dotfiles like .gitignore) to inspect directory contents before making changes
-
- Create and manage files directly from the terminalBuild project directory structures and create files without leaving the command line, enabling rapid scaffolding of Python projects and eliminating dependency on graphical file managers.
- Use mkdir with the -p flag to create nested directory trees like mkdir -p src/models/tests in a single command
- Use touch to create empty files such as init.py or README.md and rm to remove files you no longer need
- Use mv to rename or relocate files and cp to duplicate files across directories, both essential when reorganizing a project layout
-
- Install and configure VS Code as your primary Python editorDownload, install, and verify that VS Code runs correctly on your operating system so it is ready to serve as the central tool where you write, run, and debug Python code.
- Download the correct VS Code installer for your operating system from the official site and verify the application launches from both the desktop and the terminal via the code command
- Configure essential editor settings including tab size set to 4 spaces (PEP 8 standard), auto-save enabled, and the integrated terminal pointing to your default shell
- Open a project folder in VS Code using code . from the terminal so the editor's file explorer reflects your actual directory structure
-
- Configure the VS Code Python extension for interpreter detection and lintingInstall the Microsoft Python extension and verify it correctly detects your Python interpreter, enabling syntax highlighting, error checking, and IntelliSense autocompletion before you write your first script.
- Install the Python extension by Microsoft from the Extensions Marketplace and confirm it appears in your active extensions list with no errors
- Use the Ctrl+Shift+P command palette to run "Python: Select Interpreter" and choose the correct Python 3 binary, avoiding common issues where the extension defaults to Python 2 or a virtual environment you did not intend
- Verify the extension works by opening a .py file, intentionally introducing a syntax error like a missing colon after an if statement, and confirming that VS Code underlines the error before you run the file
Key Terminology
Terminal
A text-based application that accepts typed commands and sends them to the operating system's shell for execution, replacing the need to click through graphical menus.
Shell
The program running inside the terminal that interprets your commands, with common examples being Bash on Linux, Zsh on macOS, and PowerShell on Windows.
Command line
The text prompt displayed by the shell where you type commands, often showing your username, hostname, and current directory before a **$** or **%** character.
Filesystem
The hierarchical tree structure an operating system uses to organize files and directories on disk, starting from a root directory (**/** on macOS/Linux or **C:\** on Windows).
Working directory
The directory your terminal session is currently operating in, which determines how relative paths like **src/main.py** are resolved.
Absolute path
A file or directory path that starts from the filesystem root, such as **/home/user/projects/app.py**, and points to the same location regardless of your working directory.
Relative path
A file or directory path interpreted relative to your current working directory, such as **../tests/test_app.py**, where **..** means "one directory up."
Hidden file
A file or directory whose name begins with a dot (**.**), such as **.gitignore** or **.vscode/**, which **ls** does not display unless you pass the **-a** flag.
Home directory
The default starting directory for your user account, represented by the **~** shortcut in terminal commands, typically **/home/username** on Linux or **/Users/username** on macOS.
VS Code
Visual Studio Code, a free source-code editor by Microsoft that supports extensions, an integrated terminal, and language-specific tooling for Python and other languages.
Extension
A plugin installed into VS Code from the Marketplace that adds features such as syntax highlighting, linting, or debugger support for a specific language or framework.
Python interpreter
The executable binary (e.g., **python3**) that reads and executes Python source files, which VS Code must locate correctly to provide error checking and autocompletion.
IntelliSense
The VS Code autocompletion engine that suggests function names, method signatures, and variable types as you type, powered by the language extension's analysis of your code.
Linting
The process of statically analyzing Python source code for syntax errors, style violations, and potential bugs before you run the program, typically performed by tools like Pylint or Flake8.
Integrated terminal
The terminal panel built into VS Code that lets you run shell commands without switching to a separate application, automatically scoped to your open project folder.
Command palette
The VS Code overlay activated with **Ctrl+Shift+P** (or **Cmd+Shift+P** on macOS) that provides searchable access to every editor command, setting, and extension action.