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
Popular Python guides
Most readLatest Python guides
Page 172 of 179Python NaN Comparison: Why NaN != NaN and How to Check It
python nan comparison: Learn why NaN never equals itself in Python and how to correctly check for NaN using math.isnan, numpy.isnan, and pandas.isna.
Python Float NaN: Detection and Handling
How Python float NaN behaves, why it never equals itself, and how to detect and handle NaN in data processing, serialization, and numerical computations.
Python Float Infinity: Creation, Checks, and Pitfalls
Learn how to create and test positive and negative infinity as Python floats, understand arithmetic and comparison behavior, and avoid serialization and conversion pitfalls.
Python String to Float: Conversion and Error Handling
python string to float: Learn how to convert Python strings to float using the float() function, handle ValueError, and manage edge cases like locale and precision.
Python int to float: Conversion and Precision
python int to float: Learn how to convert integers to floats in Python, including explicit and implicit conversion, precision behavior, and practical use cases.
Python round() Function: Syntax, Precision, and Pitfalls
Learn how Python's round() function handles syntax, banker's rounding, floating-point precision limits, and when to use Decimal for exact decimal arithmetic.
Python Float Rounding: How to Round Correctly
Understand how Python rounds floats, why round() can behave unexpectedly, and when to use Decimal or formatting for precise control.
Python Float Comparison: How to Compare Floats Correctly
python float comparison: Learn why direct float equality fails and how to compare floats reliably using tolerance, math.isclose, and practical testing strategies.
Python Float Precision: Handling Rounding Errors
Python floats are binary approximations. Understand why operations like `0.1 + 0.2` can be inexact, how to inspect the stored value, and when to use Decimal.
Python Floating Point: Precision, Errors, and Fixes
Learn why 0.1 + 0.2 is not 0.3 in Python, how binary floating point works, and how to compare, round, and choose the right numeric type.