Python is a high-level, interpreted, general-purpose language that emphasises readability. This lesson covers the language's core mental model, the interactive REPL, and your first working program. By the end you will understand what makes Python different from Java or C and why it dominates three of the fastest-growing fields in 2026.
What Python is
Python is a dynamically typed, garbage-collected, multi-paradigm language. The reference implementation (CPython) compiles source to bytecode and runs it on a virtual machine, the same model Java and C# use, but with a much smaller syntax surface. Code that takes fifty lines in Java often takes ten in Python, and the tradeoff is execution speed. Python pays for brevity with runtime overhead, but that cost has shrunk as interpreters and JIT compilers (PyPy, the experimental 3.13 JIT) have matured.
# A complete program in three lines
greeting = "Hello, World!"
name = "Tutorsbot"
print(f"{greeting} I am {name} learning Python in 2026.")
The REPL
Python ships with an interactive interpreter called the REPL. Run python3 with no arguments and you get a prompt where every expression you type is evaluated and printed. The REPL is your scratchpad for trying syntax, inspecting objects, and debugging interactively. Modern Python also supports the -i flag which keeps the REPL open after running a script so you can poke at its variables.
>>> 1 + 2
3
>>> "tutors".upper()
'TUTORS'
>>> import math; math.sqrt(144)
12.0
Why Python dominates three domains in 2026
Python's design tradeoff, slower execution for dramatically shorter code, wins wherever the cost of writing the code dwarfs the cost of running it. That is most of machine learning research, scientific computing, scripting, and web backends today.
| Domain | Where Python wins | Key libraries |
|---|---|---|
| Data science | NumPy, Pandas, Polars, Matplotlib form a near-universal stack | numpy, pandas, polars, matplotlib |
| ML and AI | PyTorch, TensorFlow, JAX, scikit-learn are Python-first | torch, transformers, langchain |
| Web backends | Django, FastAPI, Flask | fastapi, django, flask |
| DevOps and scripting | Replaces bash for anything non-trivial | requests, click, rich |
The CPython versions that matter in 2026
Python 3.12 is the current stable release. It brought the type statement for type aliases, the Per-Interpreter GIL (PEP 684) which lays the groundwork for true multi-core parallelism, and significantly faster CPython thanks to the faster CPython project. Python 3.13 adds a just-in-time compiler that is now opt-in. Avoid Python 2 in 2026, it reached end-of-life in 2020.
# Check your version
$ python3 --version
Python 3.12.4
# Run a script
$ python3 hello.py
Hello, World! I am Tutorsbot learning Python in 2026.
Common pitfalls when learning Python
Beginners often trip over Python's whitespace-sensitive syntax and its handling of mutable defaults. The first is non-negotiable: indentation defines blocks, and mixing tabs with spaces raises IndentationError at parse time. Configure your editor to use four spaces and turn on the visible whitespace indicator. The second is subtler. Default argument values are evaluated once at function definition time, not on every call, so def add(item, bucket=[]) appends to the same list forever. Always default to None and create the container inside the body. A third trap is confusing assignment and copying for nested data. Writing new = old does not deep-copy; if old contains a dict, mutating new["x"] also mutates old["x"]. Use copy.deepcopy when you truly need an independent structure. A fourth trap is using == where you wanted is; == compares values, is compares object identity, and they are not interchangeable for mutable objects.
How Python compares to JavaScript and C++
Compared to JavaScript, Python uses indentation instead of braces, refuses implicit type coercion between unrelated types, and treats True and False as keywords rather than aliases for 1 and 0. Python also has no automatic semicolon insertion, so each statement is one line unless you break it explicitly with a backslash or open parenthesis. Compared to C++, Python manages memory automatically, ships with a batteries-included standard library, and forces you to think about interfaces rather than memory layouts. The cost is execution speed: tight numeric loops in C++ run roughly an order of magnitude faster than the same loop in CPython. For the workloads Python dominates (data wrangling, glue code, model serving, scripting), the readability win is worth the speed loss. For systems code, kernels, or game engines, reach for C++, Rust, or Mojo.
Best practices in 2026
Three habits separate a productive Python developer from someone who struggles with the language. First, use a virtual environment for every project so package versions do not collide. uv has replaced virtualenv for most teams in 2026 because it is faster and self-bootstrapping and it understands pyproject.toml natively. Second, format with ruff or black and lint with ruff or flake8 so style debates disappear from code review. Third, write type hints on every public function and run mypy in strict mode. The annotations are not overhead; IDEs, refactoring tools, and even the runtime dataclasses machinery all rely on them. Combine these three with a test runner (pytest) and you have a default stack that scales from a five-line script to a thousand-module monorepo without forcing anyone to relearn the conventions.
Putting it together — a real-world example
Imagine a small CLI tool that reads JSON records from standard input and prints the average of a chosen numeric field. Python expresses it in under thirty lines and the result is debuggable from the REPL one expression at a time.
import json
import sys
from statistics import mean
def average_field(records, field):
values = [r[field] for r in records if field in r]
if not values:
raise ValueError(f"no records contained field {field!r}")
return mean(values)
if __name__ == "__main__":
records = [json.loads(line) for line in sys.stdin if line.strip()]
field = sys.argv[1] if len(sys.argv) > 1 else "score"
print(f"{field}: {average_field(records, field):.2f}")
That single file replaces the equivalent bash pipeline plus a small C helper. Save it as avg.py, run python3 avg.py score, and pipe JSON Lines data through it. Python scripts are first-class command-line programs; treat the shebang line and __main__ guard as table stakes for anything you intend to run more than once.
Summary
Python rewards readable code over clever code. Install Python 3.12, open the REPL, and run the snippets above. The next lesson walks you through installation and the tooling that surrounds modern Python development.