EXERCISE
1Not all numbers are created equal — some can only be whole numbers, and others can be infinitely precise.
Save
Think of discrete data like stairs — you step from one whole number to the next. Continuous data is like a ramp — you can stop at any point, including 3.7 or 3.14159.
Discrete data: countable, whole numbers
# Number of cars passing by — you cannot have 3.5 cars
cars_per_hour = [12, 15, 8, 22, 17, 9]
print(sum(cars_per_hour))
# Output: 83
# These are always integers
Continuous data: measurable, any value
# Temperature can be ANY value on the scale
temperatures = [36.6, 37.2, 36.8, 38.1, 36.5]
print(round(sum(temperatures) / len(temperatures), 2))
# Output: 37.04
# Price can have decimals
prices = [9.99, 24.50, 3.75, 149.99]
print(min(prices))
# Output: 3.75
Quick reference:
| Property | Discrete | Continuous |
|---|---|---|
| Values | Whole numbers only | Any value (decimals ok) |
| Measured by | Counting | Measuring |
| Examples | Students in class, dice rolls | Height, weight, time |
| Can be 3.5? | ❌ No | ✅ Yes |
> 💡 Key Insight: This distinction matters in ML because different algorithms handle discrete and continuous data differently. algorithms predict discrete labels (spam/not spam). algorithms predict continuous values (price, ).