#!/usr/bin/env python # coding: utf-8 # # Chapter 5: Numbers & Bits (TL;DR) # There exist three numeric types in core Python: # - `int`: a near-perfect model for whole numbers (i.e., $\mathbb{Z}$); inherently precise # - `float`: the "gold" standard to approximate real numbers (i.e., $\mathbb{R}$); inherently imprecise # - `complex`: layer on top of the `float` type to approximate complex numbers (i.e., $\mathbb{C}$); inherently imprecise # # Furthermore, the [standard library ](https://docs.python.org/3/library/index.html) provides two more types that can be used as substitutes for the `float` type: # - `Decimal`: similar to `float` but allows customizing the precision; still inherently imprecise # - `Fraction`: a near-perfect model for rational numbers (i.e., $\mathbb{Q}$); built on top of the `int` type and therefore inherently precise # # The *important* takeaways for the data science practitioner are: # # 1. **Do not mix** precise and imprecise data types, and # 2. actively expect `nan` results when working with `float` numbers as there are no **loud failures**. # # The **numerical tower** is Python's way of implementing various **abstract** ideas of what numbers are in mathematics.