Difference between / vs. // operator in Python
Last Updated :
18 Sep, 2025
In Python, both / and // are used for division, but they behave quite differently. Let's dive into what they do and how they differ with simple examples.
/ Operator
This operator is used for true division. No matter what the inputs are, result is always a floating-point number. Even if division is exact, Python still returns the result as a float. This operator preserves fractional part of the result.
Example: Here we divide 10 by 3 using /. Since / does true division, it keeps the decimal part.
Python
res = 10 / 3
print(res)
print(type(res))
Output3.3333333333333335
<class 'float'>
Explanation: Dividing 10 by 3 gives 3.333... and / operator preserves the fractional value. The datatype of res is float.
// Operator
This operator is used for floor division. Instead of keeping fractional part, it returns largest integer less than or equal to the result. In other words, it rounds down answer towards negative infinity.
Example: Here we divide 10 by 3 using //. Unlike /, this operator removes the fractional part.
Python
res = 10 // 3
print(res)
print(type(res))
Explanation: actual division result is 3.333..., but // truncates everything after decimal, giving 3. The datatype of res here is int.
Key Difference: Negative Numbers
The most noticeable difference between / and // appears when negative numbers are involved.
Example: Here we divide -17 by 5 using both / and //.
Python
print(-17 / 5)
print(-17 // 5)
Explanation:
- / gives the exact decimal value (-3.4).
- // rounds down towards negative infinity, so instead of -3, it becomes -4.
Comparison between / and //
To sum up everything we discussed above, here is the difference in tabular form:
| Feature | Division / | Floor Division // |
|---|
| Return Type | Always returns float (even if the result is a whole number) | Returns int if both operands are integers, otherwise float |
|---|
| Fractional Part | Keeps the fractional/decimal part | Removes the fractional part (rounds down) |
|---|
| Positive Example | 7 / 2 = 3.5 15 / 4 = 3.75 | 7 // 2 = 3 15 // 4 = 3 |
|---|
| Negative Example | -9 / 2 = -4.5 -22 / 4 = -5.5 | -9 // 2 = -5 -22 // 4 = -6 |
|---|
Related articles: Python, Python Operators.
Explore
Python Fundamentals
Python Data Structures
Advanced Python
Data Science with Python
Web Development with Python
Python Practice