Skill-Lite

Practical tutorials & tools for modern developers.

Home/Python/Introduction

Introduction to Python

Python is a high-level, interpreted, general-purpose programming language prized for readable syntax and a massive ecosystem. It's the default language for data science, machine learning, automation, web backends, and scripting — and the foundation for the NumPy, Pandas, and Matplotlib libraries covered later in this tutorial.

Why Python?

TraitWhy it matters
Readable syntaxIndentation-based blocks, no braces or semicolons — code reads close to plain English
Dynamically typedNo type declarations; variables can hold any type and can be reassigned
Batteries includedRich standard library — files, JSON, HTTP, dates, regex — with no extra install
Huge ecosystemNumPy, Pandas, Matplotlib, Django, FastAPI, PyTorch, TensorFlow via pip
InterpretedRuns line by line — fast feedback loop, no separate compile step
Cross-platformSame code runs on Windows, macOS, and Linux

Installing Python

Download the latest release from python.org, or use a package manager. Verify the install with:

python --version
# or on some systems:
python3 --version

pip --version           # pip ships with modern Python installers
Windows tip: During installation, check "Add python.exe to PATH" so the python command works from any terminal.

Running Python code

MethodCommandUse case
REPL (interactive shell)pythonQuick experiments, one-off checks
Script filepython app.pyReal programs, saved and re-runnable
Module flagpython -m http.serverRun an installed package as a program
NotebookJupyter / VS Code notebooksData exploration, mixing code with output & charts

Your first program

# hello.py
name = "World"
print(f"Hello, {name}!")

# Run it:
#   python hello.py
# Output:
#   Hello, World!

Comments and style (PEP 8)

# A single-line comment starts with '#'

"""
A triple-quoted string used as a
multi-line comment or docstring.
"""

def greet(name):
    """Return a friendly greeting for `name`."""   # docstring — describes the function
    return f"Hello, {name}!"

Python's official style guide is PEP 8: 4-space indentation, snake_case for variables and functions, PascalCase for classes, and constants in UPPER_CASE. Consistent indentation isn't just style in Python — it defines code blocks, so mixing tabs and spaces will cause errors.

Packages and virtual environments

Third-party libraries are installed with pip, Python's package manager. A virtual environment isolates a project's dependencies from your system Python and from other projects.

# Create an isolated environment
python -m venv .venv

# Activate it
.venv\Scripts\activate      # Windows
source .venv/bin/activate   # macOS / Linux

# Install packages into the active environment
pip install numpy pandas matplotlib

# Freeze exact versions for reproducibility
pip freeze > requirements.txt
pip install -r requirements.txt

The data-science stack

Python

  • Core language
  • Syntax & control flow
  • Standard library

NumPy

  • N-dimensional arrays
  • Vectorized math
  • Foundation library

Pandas

  • DataFrames & Series
  • Tabular data
  • Built on NumPy

Matplotlib

  • Charts & plots
  • Visualize results
  • Works with both

This tutorial follows that exact order: Python fundamentals first, then NumPy for numerical arrays, Pandas for tabular data analysis built on top of NumPy, and finally Matplotlib to visualize the results of both.

Next up: Python Basics covers variables, data types, control flow, functions, and object-oriented programming — the fundamentals every later page builds on.