Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python is a high-level language whose readable syntax, extensive standard library, and large package ecosystem make it useful for automation, web services, data work, testing, and scripting. This guide targets developers who already understand programming fundamentals but are new to Python. The examples target Python 3.14; the official documentation index identifies Python 3.14.7 documentation, updated September 28, 2026 (official Python documentation).

If you are completely new to programming, learn variables, control flow, functions, and debugging concepts first. The official Python tutorial explicitly describes itself as being for programmers new to Python, not beginners new to programming.

Choose the right Python reference

Python documentation is easier to use when each resource has a defined job:

Resource Best use What to expect
Python Tutorial Learn the language progressively Informal introduction; useful starting point, not a comprehensive reference
Language Reference Resolve syntax and semantic questions Exact and complete, but terse
Standard Library reference Look up built-ins and modules shipped with Python API-focused; available modules can vary by platform and distribution
Documentation index Check version-specific manuals Navigation to tutorials, references, setup, and packaging guidance

When behavior may differ between releases, check the manual for the interpreter you actually run rather than relying on an older example.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Python and create an isolated project

Install Python 3.14 from your operating system or the official distribution, then verify the executable:

python3 --version
# Windows PowerShell
py --version

The Python 3.14 installation guide identifies pip as the preferred package installer and venv as the standard tool for virtual environments (installation guide).

  1. Create a project directory and enter it.
  2. Create a virtual environment: python3 -m venv .venv (Windows: py -m venv .venv).
  3. Activate it: source .venv/bin/activate on macOS/Linux, or .venvScriptsActivate.ps1 in PowerShell.
  4. Upgrade packaging tools when appropriate: python -m pip install --upgrade pip.
  5. Install project dependencies with python -m pip install package-name.

On Linux, avoid indiscriminately installing into the distribution’s system interpreter. The official guide warns that pip changes can interfere with software managed by the operating system. A project-specific virtual environment keeps dependencies and upgrades separate.

Core Python syntax and data structures

Names, values, and indentation

Python uses indentation to delimit blocks. Four spaces is the conventional style; mixing tabs and spaces can produce errors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
name = "Ada"
count = 3
if count > 0:
    print(f"{name} has {count} tasks")

Variables refer to objects. Assignment does not copy an object automatically, so understand mutability when sharing lists, dictionaries, or sets.

Built-in collections

  • list: ordered, mutable sequence, such as ["draft", "published"].
  • tuple: ordered, immutable sequence, such as (width, height).
  • dict: key-value mapping, such as {"status": 200}.
  • set: collection of unique values, useful for membership tests.
users = [{"name": "Ada", "active": True}, {"name": "Lin", "active": False}]
active_names = [u["name"] for u in users if u["active"]]
print(active_names)

Control flow

for number in range(5):
    if number % 2 == 0:
        print(number, "even")
    else:
        print(number, "odd")

Use for to iterate over items, while when a condition controls repetition, and match when structural pattern matching makes cases clearer. Prefer straightforward loops over compressed expressions when readability suffers.

Functions and type hints

def total(prices: list[float], tax_rate: float = 0.0) -> float:
    subtotal = sum(prices)
    return subtotal * (1 + tax_rate)

print(total([10.0, 5.0], tax_rate=0.2))

Type hints document intent and help editors and static-analysis tools; Python does not enforce them at runtime by itself. Keep functions small, name parameters clearly, and return one well-defined result.

Exceptions, files, and context managers

Handle exceptions at the boundary where you can recover or add useful context. Do not catch every exception silently.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from pathlib import Path

path = Path("settings.txt")
try:
    text = path.read_text(encoding="utf-8")
except FileNotFoundError:
    text = ""
except OSError as exc:
    raise RuntimeError(f"Could not read {path}") from exc

A with statement guarantees cleanup for resources such as files, locks, and network clients:

with Path("output.txt").open("w", encoding="utf-8") as file:
    file.write("donen")

Modules, packages, and project structure

Put reusable code in modules and import it from an explicit entry point. A small project can start as:

project/
├── .venv/
├── pyproject.toml
├── src/
│   └── example_app/
│       ├── __init__.py
│       └── cli.py
└── tests/
    └── test_cli.py

Use absolute imports such as from example_app.cli import main. Guard executable code so importing a module does not run the application:

def main() -> int:
    print("Hello")
    return 0

if __name__ == "__main__":
    raise SystemExit(main())

For distributable projects, describe metadata and dependencies in pyproject.toml. Pin or constrain dependencies according to your release policy, and record the environment used to build and test the project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Testing, debugging, and quality practices

Write focused tests

def slugify(value: str) -> str:
    return "-".join(value.lower().split())

def test_slugify():
    assert slugify("Hello Python") == "hello-python"

Run tests from the activated environment with your chosen test runner. Keep tests deterministic, isolate filesystem and network effects, and include failure cases as well as successful inputs.

Use the standard debugging tools

  • Add temporary logging with the logging module instead of scattered prints in long-running programs.
  • Use breakpoint() to enter the debugger at a suspicious line.
  • Read the final exception and traceback frame first; it usually identifies the failing operation and location.
  • Reproduce a failure in the smallest possible input before changing code.

Concurrency and I/O choices

Choose the model that matches the bottleneck. Ordinary synchronous code is simplest for sequential work. Threads can help when tasks spend time waiting on blocking I/O. Processes are useful for CPU-heavy independent work. asyncio coordinates many cooperative I/O operations when the libraries you use support asynchronous APIs. Do not introduce asynchronous code merely to make a small script look faster; measure the actual bottleneck and preserve cancellation and error handling.

Common errors and their fixes

Symptom Likely cause Fix
python: command not found Interpreter is not installed or not on PATH Install Python, use the platform launcher (py on Windows), and verify PATH.
ModuleNotFoundError Package installed in another interpreter or environment Activate .venv; install with python -m pip; print import sys; print(sys.executable).
Permission or externally managed environment error Attempt to modify an OS-managed Python Create and activate a project venv instead of using system-wide pip.
SyntaxError near an otherwise valid line Earlier unmatched quote, bracket, or indentation Inspect the preceding lines and run the file with the intended Python version.
Changes appear ignored Old bytecode, wrong working directory, or imported module cached in a running process Restart the process, print paths, and confirm which module file was imported.

Practical Python example: request a website screenshot

For a browser-controlled workflow, install a browser automation library, launch a headless browser, navigate to the URL, wait for the page state you need, and save the image. Browser automation is useful when you must interact with the page, inspect DOM state, or reproduce a user flow. It also means managing browser binaries, timing, consent dialogs, popups, and failures yourself.

Whatever library you choose, protect credentials, set navigation and operation timeouts, close the browser in a finally block, and treat a screenshot as an artifact whose URL, viewport, and timestamp should be recorded for reproducibility.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. One request can return PNG, JPEG, WebP, or PDF. Before capture it accepts cookie/consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.

Python:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

See the ScreenshotNeo API documentation for all options, including viewport and device presets, full-page and element capture, JavaScript and CSS, waits, request blocking, cookies, headers, geolocation, PDF settings, resizing, caching, signed links, asynchronous webhooks, bulk capture, usage, and OpenAPI details.

cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.

Keep learning without getting lost

Use the tutorial for a guided first pass, then switch to the language reference when exact syntax or semantics matter and the standard-library reference when you need a module’s API. Read version-specific documentation, keep each project in a virtual environment, and build small programs that you can test and inspect. Books can provide deeper, curated coverage, but they are optional; the official tutorial itself points readers toward the references and books for continued study.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Which Python version should a new project use?

Use the newest version supported by your dependencies and deployment environment. This guide’s examples target Python 3.14; verify version-sensitive behavior in the documentation for the interpreter you will run.

Do I need to learn the entire standard library?

No. Learn the core language, then look up the standard-library module that fits the task. The library reference is designed for that focused lookup.

Why does pip install into the wrong place?

The command may be running outside your project virtual environment. Activate `.venv` and use `python -m pip` so pip is tied to the interpreter executing your code.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.