MWZ

MINDWAREZONE

beginnerPython

What is the difference between / and //?

Answer

Clear, interview-ready explanation

The / operator performs regular division and normally returns a floating-point result.

The // operator performs floor division. It rounds the result down to the nearest whole value.

print(7 / 2) 
print(7 // 2)
            

Output:

3.5 3
            

Floor division rounds toward negative infinity, not toward zero:

print(-7 // 2)
            

Output:

-4
            

If either operand of floor division is a float, the result is also a float:

print(7.0 // 2)
            

Output:

3.0