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

Diagram of a Python float showing its binary representation with precision boundaries and a magnifying glass highlighting rounding error.
Python

Python Float Usage: Precision, Comparisons, Formatting

Learn practical Python float usage: precision limits, safe comparisons, formatting, conversions, and when to use Decimal.

pythonfloatprecisiondecimal
A diagram showing a Python integer growing beyond 64 bits into multiple digit blocks, illustrating arbitrary precision.
Python

Python Arbitrary Precision Integers Explained

Explains how Python's arbitrary precision integers work, highlights their performance and memory costs, and describes when fixed-width numeric types are the better choice.

arbitrary precisioninteger arithmeticCPython internalsnumeric types
Python code showing int() with base parameter converting binary and hexadecimal strings to decimal integers.
Python

Python int Base Conversion: Using int() with Different Bases

python int base conversion: Learn how Python's int() converts strings and numbers between bases, with syntax, error handling, and edge cases for base 2 to 36.

int()base conversionradixnumber parsing
Diagram showing conversion between a Python integer and its hexadecimal string representation.
Python

Python Hexadecimal Integer: Conversion and Formatting

Practical Python guide to converting integers to and from hexadecimal strings, formatting hex output, and using bitwise operations.

pythonhexadecimalinteger-conversionbitwise-operations
Stylized 0o755 octal literal with an arrow to its decimal equivalent 493, illustrating Python octal integer syntax.
Python

Python Octal Integer: Syntax, Conversion, and Pitfalls

Learn the python octal integer syntax in Python 3: the 0o prefix, conversions with oct() and int(), and the leading-zero SyntaxError.

octal-literalspython-syntaxnumeric-conversionfile-permissions
Illustration of a Python binary integer showing bit positions and bitwise operations
Python

Python Binary Integer: Bits and Bitwise Operations

Learn how Python represents integers in binary, how bitwise operators behave, and how to use them for practical bit manipulation.

bitwise operationsinteger representationtwo's complementbit manipulation
Illustration of a Python integer 42 transforming into a string '42' with a code editor background.
Python

Python Int to String: Convert and Format Integers

Understand how to convert Python integers to strings with str(), f-strings, and format(). Compare behavior, formatting options, and edge cases.

pythonstring-conversionf-stringsformat-specifiers
Diagram showing a float value being converted to an integer with truncation and rounding options.
Python

Python Float to Int: Truncation, Rounding, and Edge Cases

Learn how to convert Python floats to ints: int() truncates toward zero, round() rounds to nearest, and math.floor()/math.ceil() round in a specific direction. Includes NaN, infinity, and precision edge cases.

float conversionint() functionroundingtruncation
An illustration showing a string of text characters transforming into a solid integer block with an arrow, representing the int() conversion in Python.
Python

Python String to Int Conversion with int()

Learn how to convert Python strings to integers with int(), including custom bases, ValueError handling, and practical parsing patterns.

Pythontype-conversionerror-handlinginput-parsing
Illustration of a Python int conversion showing a string being transformed into an integer with error handling in the background
Python

Python Int Conversion: Syntax, Edge Cases, and Pitfalls

Learn how Python's int() converts strings, floats, and other values to integers, handles invalid input, and works with custom bases.

int()type conversionPython stringsValueError handling