Getting Started
🐍 Getting Started with Python
print(), comments, and the python3 vs python command distinction that trips up almost everyone at least once.
🌍 What Is Python, and Why Learn It?
Python is:
- Interpreted — no separate compile step; a script runs directly, unlike Go, Rust, or Kotlin, all already covered on this site
- Dynamically typed — a variable's type is determined at runtime, not checked at compile time (the opposite of Kotlin's or TypeScript's static typing)
- General-purpose — web backends, scripting/automation, data science, and more, all with the same core language
- "Batteries included" — a large standard library covers files, networking, dates, and more with no extra installs
- Readability-focused — indentation is part of the syntax itself, not just a style convention
Python vs Go vs Kotlin, at a Glance
| Trait | Go | Kotlin | Python |
|---|---|---|---|
| Execution model | Compiled to a binary | Compiled to JVM bytecode | Interpreted directly |
| Typing | Static | Static, inferred | Dynamic |
| Block structure | Braces { } | Braces { } | Indentation only |
| Entry point | func main() | fun main() | No special entry function required |
💾 Installing Python & Checking It Works
Install from python.org (Windows/Mac) or your system's package manager (apt install python3 on Debian/Ubuntu, already familiar from the Linux courses). Verify the install from a terminal:
▶️ The REPL — Python's Interactive Shell
Running python3 with no arguments drops into an interactive shell — try expressions immediately, no file needed:
Like Node's REPL
If you've used node with no arguments (Node.js Course 1), this is the exact same idea — an interactive prompt for trying things out immediately, no file or compile step needed.
Exiting the REPL
Type exit(), or press Ctrl+D (Mac/Linux) / Ctrl+Z then Enter (Windows).
📄 Running a Python Script
hello.py
Run it:
No compile step, no entry-point function to declare — the script's top-level code just runs, top to bottom, the moment the interpreter reaches it.
🖨️ print() — Python's console.log
print() accepts any number of comma-separated arguments, joining them with a space and adding a trailing newline by default — both behaviors are customizable with the sep and end keyword arguments.
💬 Comments
Python has no dedicated multi-line comment syntax like /* */ — a triple-quoted string not assigned to anything is commonly used instead, and the same syntax doubles as a docstring when placed as the first line inside a function, class, or module (covered properly once functions are introduced in Chapter 8).
🐍 python3 vs python — Why It Matters
Python 2 reached end-of-life in 2020, but its legacy lives on in one confusing spot: on many systems, the bare python command still points at Python 2 (or doesn't exist at all), while python3 reliably points at a modern Python 3 interpreter. Windows installers from python.org typically set up python to mean Python 3 directly, but Linux and Mac frequently don't.
Running python on a system where it's aliased to Python 2 — or where it's missing entirely — is a common source of confusing "command not found" or bizarre syntax errors for beginners following an old tutorial. Get in the habit of typing python3 and pip3 explicitly from day one; it works everywhere, with zero ambiguity.
💻 Coding Challenges
Challenge 1: Your First Script
Create a file called about_me.py that prints your name and a short greeting, using two separate print() calls. Run it with python3 about_me.py.
Goal: Get comfortable creating and running a Python script from the command line.
Challenge 2: print() Options
Write a single print() call that prints three words separated by " | " instead of a space, using the sep keyword argument.
Goal: Practice using keyword arguments to customize a built-in function's behavior.
Challenge 3: REPL Exploration
Open the REPL with python3 and try five different expressions of your choice (arithmetic, string concatenation with +, etc.). Write down what each one returned.
Goal: Build comfort using the REPL as a quick scratchpad, not just for running scripts.
Python's official installer includes IDLE, a simple built-in editor with its own REPL window — genuinely fine for these early chapters. This course doesn't require any particular editor; use IDLE, VS Code, or whatever you're already comfortable with.
🎯 What's Next
Next chapter: Variables & Basic Data Types — int/float/str/bool, Python's dynamic typing in practice, and using type() to check and convert between types.