Pages

Topics

Tools

↑↓navigate↵openescclose

Python guides

Every published Python guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Python guides

Illustration of Python map function transforming items in a list through a function pipeline.
Python

Python's map() Function: Usage and Tradeoffs

Learn how to use Python's built-in map() function to apply a function to iterables, understand lazy evaluation, and decide when map() is a better choice than list comprehensions.

map functionfunctional programmingiterableslist comprehension
Illustration of a Python loop showing an index counter paired with a value, representing the enumerate function's dual output.
Python

Python enumerate Function: Syntax and Examples

Learn how to use Python's enumerate() to get both index and value in loops, with practical examples and performance notes.

enumerateiterationloopsindexing
Illustration of the divmod function returning a tuple with quotient and remainder from a division operation.
Python

Python divmod Function: Quotient and Remainder Together

Learn how Python's built-in divmod function returns both the quotient and the remainder in one call, with practical examples, edge cases, and performance notes.

divmodPython built-insarithmetic operationsremainder
Illustration of the Python pow function showing exponentiation and modular arithmetic with a base, exponent, and modulus.
Python

Python pow() Function: Syntax, Modulo, and Performance

Learn how Python's pow() function supports exponentiation and modular arithmetic, including its two- and three-argument forms, edge cases, and performance trade-offs.

exponentiationmodular arithmeticbuilt-in functionsmath
A number line showing negative and positive values with an arrow indicating the absolute value transformation to the positive side.
Python

Python abs Function: Syntax, Behavior, and Alternatives

python abs function: Understand Python's abs() function: syntax, behavior with int, float, complex, custom objects, and when to use alternatives like math.fabs.

abs()Python built-in functionsnumeric typescomplex numbers
Illustration of Python sum function adding numbers from a list into a total
Python

Python sum Function: Syntax, Behavior, and Limits

Learn how Python's built-in sum() works: syntax, start parameter, performance behavior, and when to choose alternatives like math.fsum or functools.reduce.

pythonsum functionbuilt-in functionsiterables
Illustration of Python min and max functions comparing values with a key parameter
Python

Python min() and max() Functions: Syntax, key, and default

Understand Python's built-in min() and max() functions, including syntax, the key parameter, a default for empty iterables, performance, and edge cases.

python built-insmin functionmax functionkey parameter
Illustration showing a Python container with a visible length counter, representing how the len() function returns the number of items.
Python

How the Python len Function Works

python len function: Understand how Python's len() works internally, which types support it, how to implement __len__ in custom classes, and why it runs in constant time.

pythonlen functionbuilt-in functionsdunder methods
Illustration of Python built-in functions as a set of tools for code transformation and data handling.
Python

Python Built-in Functions: A Practical Guide

Python built-in functions are always available without imports. This guide explains key functions for type conversion, iteration, attribute access, and I/O with practical examples.

pythonbuilt-in functionspython standard librarycode efficiency
Illustration of a lambda function as a key that sorts a list of items in Python
Python

Python Lambda with Sorted: Custom Sorting Made Clear

python lambda with sorted: Learn how to use lambda functions with Python's sorted() to sort lists, dictionaries, and objects by custom keys, with practical examples an...

Pythonlambdasortedsorting