A real number is any value that can be placed on a continuous number line. Real numbers describe measurements that may include decimal parts, such as 6.73 miles, 5.32 miles, or half a gallon. They include rational numbers, which can be written as ratios, and irrational numbers, such as pi, e, and the square root of 2, which cannot. section 2.11
Working with real numbers involves a distinction between mathematical values and their computer representations:
- Rational values include fractions, finite decimals, and repeating decimals; Python can display examples such as 2/3, 1.572, and 55/7. section 2.11
- Irrational values have infinitely many nonrepeating decimal digits, so Python stores approximations such as 3.141592653589793 for pi. section 2.11
- Floating-point formats use limited bits, so calculations can introduce small precision errors; libraries may provide techniques for avoiding underflow and related problems. section 2.11
Whole-number measurements can still be continuous
Baristas report coffee amounts in whole grams because scales and workflows limit practical precision. The underlying amount remains continuous: a cup could theoretically require any value between those measurements. A sample with mean 27.6 grams, median 28.0 grams, and standard deviation 3.2 grams can therefore be modeled with a continuous normal distribution. section 4.3
