Monday, September 21, 2026

What Is Python?

// programming

What Is Python?

Python is a high-level, general-purpose programming language known for readable syntax and a large ecosystem of libraries. It is widely used for automation, data processing, web development, artificial intelligence, APIs and many other programming tasks.

// definition

Python is a programming language

Python is a general-purpose programming language used to express instructions that computers can execute.

It is designed around relatively clear and concise syntax, allowing many programs to be expressed with comparatively little code.

Python can be used for small scripts as well as much larger software systems.

// hello world

A Python program can be extremely simple

print("Hello, world!")

The print() function sends the text to the program's output.

Hello, world!
// files

Python source files normally use .py

hello.py automation.py data_cleaner.py api_client.py

These files contain Python source code written as plain text.

// variables

Python can store values in variables

name = "Freelance Coder" price = 25.50 quantity = 4 active = True

The variable name provides a way for later instructions to refer to the stored object.

// data types

Python has many built-in data types

Type Example
str "Hello"
int 42
float 3.14
bool True
list [1, 2, 3]
dict {"name": "Tiago"}
tuple (1, 2)
set {1, 2, 3}
NoneType None
// dynamic typing

Python is dynamically typed

A variable name does not have to be declared with a fixed type before it is used.

x = 10 x = "hello"

In this example, the name x first refers to an integer and later refers to a string.

The objects still have types. Dynamic typing means Python determines and checks those types at runtime rather than requiring every variable declaration to specify one in advance.

// operators

Python can perform calculations

a = 10 b = 3 a + b a - b a * b a / b a ** b a % b

These operators perform addition, subtraction, multiplication, division, exponentiation and remainder operations.

// lists

Lists store ordered collections

languages = [ "Python", "JavaScript", "PHP" ]

Python list indexes begin at zero.

languages[0] # "Python"
// dictionaries

Dictionaries store key-value relationships

product = { "name": "Keyboard", "price": 39.99, "stock": 12 }

Individual values can be retrieved using their keys.

product["price"] # 39.99
// conditions

Python can make decisions

age = 20 if age >= 18: print("Adult") else: print("Under 18")

The program follows different instructions depending on whether the condition is true or false.

// indentation

Indentation is part of Python syntax

Many programming languages use braces to group blocks of instructions.

Python uses indentation.

if temperature > 20: print("Warm") print("Open the window") print("Finished")

The two indented instructions belong to the if block.

Whitespace can therefore affect program meaning. Indentation is not merely visual formatting in Python.

// loops

Loops repeat instructions

for number in [1, 2, 3]: print(number)

Output:

1 2 3
// range

range() is useful for repeated operations

for i in range(5): print(i)

This produces:

0 1 2 3 4
// functions

Functions package reusable behaviour

def add(a, b): return a + b result = add(5, 7) print(result)

Output:

12

Functions help divide larger programs into smaller, reusable pieces.

// classes

Python supports object-oriented programming

class Product: def __init__(self, name, price): self.name = name self.price = price product = Product( "Keyboard", 39.99 )

Classes can define objects that combine data and behaviour.

// modules

Programs can be divided into modules

Python code stored in separate files can be imported and reused.

import math result = math.sqrt(25) print(result)

Output:

5.0
// standard library

Python includes a large standard library

A Python installation includes modules for many common programming tasks.

Files JSON CSV SQLite Dates Regular Expressions Networking ZIP Files
// packages

Additional libraries can be installed

Python has a very large ecosystem of third-party packages.

Packages are commonly installed using pip.

pip install requests

The package can then be imported into a Python program.

import requests
// environments

Projects can use virtual environments

Different projects may depend on different package versions.

A virtual environment creates an isolated Python environment for a project.

python -m venv .venv
Project A ↓ Environment A ↓ Its packages Project B ↓ Environment B ↓ Different packages
// file handling

Python can read and write files

with open( "example.txt", "r", encoding="utf-8" ) as file: text = file.read() print(text)

This makes Python useful for processing large numbers of files automatically.

// csv

Python can process CSV data

import csv with open( "customers.csv", encoding="utf-8", newline="" ) as file: rows = csv.reader(file) for row in rows: print(row)

CSV processing is useful for spreadsheets, exports, reports and data cleaning.

// json

Python works naturally with JSON

import json text = '{"name": "Alice", "active": true}' data = json.loads(text) print(data["name"])

Output:

Alice
// databases

Python can communicate with databases

Python's standard library includes support for SQLite, and third-party packages can connect to many other database systems.

Python ↓ SQL ↓ Database ↓ Rows of data
SQLite PostgreSQL MySQL SQL Server
// sqlite example

Python can create a SQLite database

import sqlite3 connection = sqlite3.connect( "products.db" ) cursor = connection.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS products ( id INTEGER PRIMARY KEY, name TEXT, price REAL ) """) connection.commit() connection.close()
// apis

Python can communicate with APIs

A Python application can send HTTP requests and process the returned information.

Python program ↓ HTTP request ↓ API ↓ JSON response ↓ Python data

A third-party library such as requests is commonly used for this.

import requests response = requests.get( "https://api.example.com/products" ) data = response.json()
// automation

Python is particularly useful for automation

A Python script can perform repetitive technical tasks without someone manually completing each step.

Read files ↓ Clean data ↓ Call API ↓ Update database ↓ Create spreadsheet ↓ Generate report
// spreadsheets

Python can work with Excel files

Libraries such as openpyxl can read, create and modify .xlsx workbooks.

from openpyxl import Workbook workbook = Workbook() sheet = workbook.active sheet["A1"] = "Product" sheet["B1"] = "Price" workbook.save( "products.xlsx" )

This can automate spreadsheet reporting and data processing.

// data

Python is widely used for data work

Data Cleaning Data Analysis Statistics Visualisation Spreadsheets Databases

Libraries such as NumPy and pandas provide additional tools for numerical and tabular data processing.

// artificial intelligence

Python is widely used in AI and machine learning

Many machine-learning and artificial-intelligence libraries provide Python interfaces.

Machine Learning Neural Networks Natural Language Processing Computer Vision

Python's role here is strengthened by its extensive scientific and data-processing ecosystem.

// web development

Python can run web applications

Python can execute on a server and generate website responses.

Browser ↓ HTTP request ↓ Python web application ↓ Database / APIs ↓ HTTP response ↓ Browser

Python web frameworks include technologies such as Django, Flask and FastAPI.

// python vs javascript

Python and JavaScript often run in different places

Python JavaScript
Commonly runs on servers or computers Runs directly in web browsers
Strong data and automation ecosystem Core language of browser interactivity
Can build back-end web services Can build front-end and back-end applications

Both languages are general-purpose enough to overlap in many areas.

// execution

How does Python code actually run?

The most widely used Python implementation is CPython.

In simplified form, CPython processes source code, compiles it into Python bytecode and executes that bytecode using its interpreter.

Python source code ↓ Compilation ↓ Python bytecode ↓ Python virtual machine ↓ Program executes

Calling Python simply "interpreted" is useful but incomplete. Python implementations can use different execution techniques. CPython normally compiles source code to bytecode before executing it.

// interactive shell

Python can also be used interactively

Python provides an interactive environment where instructions can be entered one at a time.

>>> 2 + 3 5 >>> "hello".upper() 'HELLO'

This makes it convenient for experimentation, calculations and testing small pieces of code.

// readability

Python emphasises readable syntax

Compare the structure of a simple condition:

if balance > 0: print("Positive balance")

Keywords such as if, for, in, def and return make much Python code relatively close to structured written instructions.

// uses

What is Python used for?

Automation

Repetitive computer tasks can be scripted.

Data

Files, spreadsheets and databases can be processed.

APIs

Programs can communicate with external services.

Web Development

Python can power server-side web applications.

AI

Python is widely used with machine-learning tools.

Scientific Computing

Numerical and scientific libraries support research and technical computing.

// practical example

One script can connect several technologies

CSV file ↓ Python ↓ Clean data ↓ SQLite database ↓ API request ↓ Create XLSX report ↓ ZIP output files

This ability to connect different formats, systems and services is one reason Python is particularly useful for automation and data-management work.

// mental model

The simplest way to think about Python

Data ↓ Python instructions ↓ Logic + calculations ↓ Files / APIs / databases ↓ Useful result

Python provides a language for describing the operations a computer should perform.

// summary

Instructions become automation.

Python is a high-level, general-purpose programming language with readable syntax and a large software ecosystem. It can work with files, spreadsheets, databases, APIs and websites, and is widely used for automation, data processing, scientific computing, artificial intelligence and software development.

What Is Python?

// programming What Is Python ? Python is a high-level, general-purpose programmi...