What is a float?
Not every number is a whole number. Prices, measurements, percentages, coordinates — the real world is full of decimals. Python handles these with floats.
What is a float?
A float is any number with a decimal point:
The name comes from "floating point" — a reference to how the decimal point can appear anywhere in the number.
Floats can look like whole numbers
A number doesn't have to have digits after the decimal to be a float — the decimal point alone is enough:
Same value, different type. Python treats these differently — and that will matter soon.
Floats are not always exact
Unlike integers, floats can have tiny rounding errors. This is a quirk of how computers store decimal numbers:
That's not a Python bug — it's how floating point arithmetic works on every computer. For most programs it doesn't matter, but it's worth knowing it exists.
Key takeaways
- A float is any number with a decimal point
5and5.0look similar but Python treats them as different types- Floats can have tiny rounding errors — this is normal and expected
No comments yet. Add the first comment to start the discussion.