Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:
>>> 6/3
2
>>> 6//3
2
Python 2.7 and other upcoming version of python:
/
)Divides left hand operand by right hand operand
Example: 4 / 2 = 2
//
)The division of operands where the result is the quotient in which the digits after the decimal point are removed. But if one of the operands is negative, the result is floored, i.e., rounded away from zero (towards negative infinity):
Examples: 9//2 = 4
and 9.0//2.0 = 4.0
, -11//3 = -4
, -11.0//3 = -4.0
Both /
Division and //
floor division operator are operating in similar fashion.