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 implicit type conversion showing numeric types merging into a float
Python

Python Implicit Type Conversion Explained

python implicit type conversion: Learn how Python performs implicit type conversion, where it applies, and how to avoid common pitfalls in arithmetic, comparisons, and...

type coercionnumeric promotionPython data typesdynamic typing
Illustration of Python explicit type conversion showing arrows between int, float, and str type boxes.
Python

Python Explicit Type Conversion: int(), float(), str()

Practical guide to Python explicit type conversion with int(), float(), and str(), including edge cases and error handling.

Pythontype conversiontype castingdata types
Illustration of Python type conversion showing data flowing between integer, string, and list containers.
Python

Python Type Conversion: Implicit vs Explicit

Learn the difference between implicit and explicit type conversion in Python, when to use built-in functions like int(), str(), and list(), and how to avoid common conversion pitfalls.

type conversionpython built-insimplicit conversionexplicit conversion
Diagram showing Python boolean expression evaluation with and/or operators and truthiness.
Python

Python Boolean Expression: Truthiness and Operators

Understand Python boolean expressions: truthiness, and/or/not operators, short-circuiting, operator precedence, and common pitfalls.

boolean logictruthinessshort-circuit evaluationoperator precedence
Python code snippet showing short-circuit evaluation with and and or operators returning operand values
Python

Python Short Circuit Evaluation Explained

Learn how Python's short-circuit evaluation works with `and` and `or`, including operand return values, common use cases, and pitfalls.

Boolean OperatorsPython and orConditional LogicCode Optimization
Diagram showing Python's or operator returning a truthy value while the bitwise pipe operator combines binary bits.
Python

Python or vs |: Logical vs Bitwise

python or vs |: Understand the difference between Python's `or` logical operator and the `|` bitwise operator, including type unions and common pitfalls.

Pythonlogical operatorsbitwise operatorstype hints
Illustration contrasting Python's logical and operator with the bitwise and operator, showing two distinct paths merging into a single result.
Python

Python and vs &: Logical and Bitwise Operators

python and vs &: Explains the difference between Python's `and` and `&` operators, covering precedence, short-circuiting, and common mistakes.

Python operatorslogical operatorsbitwise operatorsoperator precedence
Illustration of the Python not operator negating a boolean value
Python

Python Not Operator: Usage and Pitfalls

Understand how Python's not operator works: truthiness rules, operator precedence, and common mistakes to avoid when writing boolean logic.

Pythonboolean logicoperator precedencetruthiness
Illustration of Python's or operator choosing between two operands based on truthiness, with a short-circuit path skipping the right side.
Python

Python or Operator: How It Really Works

Learn how Python's or operator returns one of its operands instead of a boolean, how truthiness drives the result, and why falsy values can cause surprising fallback behavior.

pythonboolean-logicshort-circuit-evaluationtruthiness
Illustration of the Python and operator showing two operands and short-circuit evaluation
Python

Python and Operator: Syntax, Short-Circuiting, and Precedence

Understand how Python's `and` operator evaluates expressions, short-circuits, and interacts with precedence to write clearer, more efficient conditions.

boolean logicshort-circuit evaluationoperator precedencePython syntax