Which one of these is floor division?
A)
/
B)
//
C)
%
D)
None of the mentioned.
Answer: B) //
You use floor division operator //
or the floor()
function of the math module to get the floor division of two integers. It returns floor value for both integer and floating point arguments.
Example:
print( 10 // 3)
print( -10 // 2)
print( 7.0 // 2)
print( - 7.0 // 2)
# Output:
3
-5
3.0
-4.0
Additional information
Example
: using /
operator:
number_1 = 10
number_2 = 3
print(number_1//number_2)
# Output:
# 3.3333333333333335
The operator /
returns float values.