Programming languages

Python

A readable general-purpose language: web, data, automation and machine learning.

What it is

Guido van Rossum created Python, with a first release in 1991. It is dynamically typed, interpreted, and uses indentation instead of braces.

Its main strength is the ecosystem: NumPy, pandas, PyTorch and scikit-learn for data and ML, Django, FastAPI and Flask for the web, Ansible and scripts for automation. Packages are installed with pip or uv.

The reference implementation CPython is developed by the community under the Python Software Foundation. Changes go through PEPs. It is slower than compiled languages, but heavy computation is usually pushed into C extensions.

Use it when

  • Data, analytics, ML and AI: nearly every library lands here first.
  • Automation scripts, scraping, DevOps tooling.
  • A backend on Django or FastAPI when development speed matters.
  • Learning to program: simple syntax.

Avoid it when

  • Services with strict latency and per-core throughput needs: Go, Rust and Java are faster.
  • Mobile apps and browser frontends.
  • Large codebases without type hints and tests: dynamic typing makes refactoring harder.

Key concepts

GIL
Global Interpreter Lock: in standard CPython only one thread runs bytecode at a time. For CPU work use processes.
Virtual environment
An isolated environment with its own packages per project (venv, uv).
Type hints
Optional type annotations checked by mypy or pyright. Not enforced at runtime.
Generators
Functions with yield return values one by one without holding the whole collection in memory.
Decorators
Functions that wrap other functions: logging, caching, authorization.

Example

Counting the most common words with the standard library.

Cheat sheet

Python cheat sheet
Command or codeWhat it does
python -m venv .venvCreates a virtual environment
source .venv/bin/activateActivates the environment
pip install requestsInstalls a package
[x * 2 for x in nums if x > 0]List comprehension with a filter
{k: v for k, v in pairs}Dict comprehension
with open('f.txt') as f:Safe file opening
def f(a, *args, **kwargs):Arbitrary positional and keyword arguments
f'{name}: {value:.2f}'f-string with formatting
for i, x in enumerate(items):Loop with an index
python -m pytest -qRuns the tests

How to learn it

  1. Install Python 3 and take the Python essentials course on ShortLesson.
  2. Learn basic types, conditions, loops, functions and string handling.
  3. Study lists, dicts, sets and list comprehensions.
  4. Learn to read and write files, work with JSON and handle exceptions.
  5. Work in a virtual environment: venv and pip, then uv.
  6. Build a small CLI or script that automates something in your own life.
  7. Add OOP, modules and tests with pytest.
  8. Pick a direction: web with FastAPI or Django, data, or automation.

Interview questions

  1. 1. What is the GIL?

    The Global Interpreter Lock lets only one thread run Python bytecode at a time in CPython. So threads do not speed up CPU-bound tasks, and multiprocessing is used instead. For I/O, threads and asyncio work well.

  2. 2. How does a list differ from a tuple?

    A list is mutable, a tuple is immutable. A tuple can be a dict key and is slightly lighter. Tuples suit fixed records.

  3. 3. What is a decorator?

    A function that takes a function and returns a new one, adding behavior such as caching, logging or permission checks. It is written as @decorator above the definition.

  4. 4. What are generators for?

    They produce values lazily, one at a time, with yield. That saves memory on large data streams, for example when reading a big file.

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).