Getting Started

Python Fundamentals — Getting Started
Python Fundamentals
Course 1 · Chapter 1 · Getting Started

🐍 Getting Started with Python

Python is a high-level, interpreted, general-purpose language prized for readability — it's used everywhere from quick scripts to web backends (Django and FastAPI, both already on this site) to data science and automation. This chapter covers what Python is and why it's worth learning, installing it, the interactive REPL, running scripts, 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

TraitGoKotlinPython
Execution modelCompiled to a binaryCompiled to JVM bytecodeInterpreted directly
TypingStaticStatic, inferredDynamic
Block structureBraces { }Braces { }Indentation only
Entry pointfunc 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:

$ python3 --version Python 3.12.1

▶️ The REPL — Python's Interactive Shell

Running python3 with no arguments drops into an interactive shell — try expressions immediately, no file needed:

$ python3 Python 3.12.1 (main, Dec 7 2023, 00:00:00) >>> 2 + 2 4 >>> print("hello") hello >>> exit()

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

# hello.py print("Hello, Python!")

Run it:

$ python3 hello.py Hello, Python!

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("The answer is", 42) # The answer is 42 — multiple args, auto-spaced print("a", "b", "c", sep="-") # a-b-c — sep changes the joiner print("no newline", end="") # end changes what's printed after (default: newline)

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

# A single-line comment """ A triple-quoted string used as a multi-line comment or a docstring — common right under a function/class definition """

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.

⚠ Always Use python3 (and pip3) Explicitly

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.

→ Solution

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.

→ Solution

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.

→ Solution

💡 IDLE: Python's Bundled Editor

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 Typesint/float/str/bool, Python's dynamic typing in practice, and using type() to check and convert between types.