Python Numeric Data Types: int, float, Decimal and When to Use Each
Python numeric data types explained: int, float, Decimal, Fraction and complex, why 0.1 + 0.2 is not 0.3, and how to handle money without rounding errors.
Search
10 articles matched your search.
Python numeric data types explained: int, float, Decimal, Fraction and complex, why 0.1 + 0.2 is not 0.3, and how to handle money without rounding errors.
Python operators explained with outputs for every example, plus why is works for 256 but fails for 257 and why and/or rarely return booleans.
NumPy tutorial for beginners: what an array is, why it ran about 20 times faster than a list here, how one stray string turns numbers into text, and more.
How to use Python tuples well: creating them, unpacking, using them as dict keys, named tuples, and the one-element and += gotchas that catch everybody.
NumPy aggregation along axes, NaN-safe statistics, argmax, sorting and linalg.solve, plus why NumPy and pandas return different standard deviations.
Python classes and objects explained with tested code: __init__, self, dunder methods, properties and dataclasses, plus the shared-list bug to learn first.
Exception handling in Python done properly: try, except, else and finally, custom exceptions, chaining and logging, and why a bare except can break Ctrl-C.
How to write Python functions: arguments, defaults, *args and **kwargs, scope, type hints and docstrings, plus the mutable default bug everyone hits once.
Lists vs tuples in Python beyond 'one is mutable': the real differences in hashability, memory, safety and intent, plus a decision rule that works in practice.
Iterators and generators in Python explained: yield, pipelines that stream big files in flat memory, itertools, and why a generator silently runs only once.