/ True division
Last updated: 2026-09-22
/ True division
/ always returns float; use // for integer division.
| Category | Operators |
|---|---|
| Kind | Operator |
| Python Version | all |
📝 Syntax
a / b
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
3.5
3.5
float
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhy is 7 / 2 equal to 3.5 rather than 3?
ABecause `/` is true division and always returns a float. For integer division use `//`, and for the remainder use `%`. Python 2's `/` did floor division, but Python 3 changed it to true division.
QWhat happens when the divisor is 0?
AIt raises `ZeroDivisionError: division by zero`, and dividing floats by 0 does the same. Check the divisor before dividing, or catch it with `try`/`except`.
QDoes dividing large integers lose precision?
AYes. Any result that is a float is bounded by float precision; for example `10**30 / 1` yields an approximation. For an exact integer result, use `//`.