+ 1
Division vs floor division
Why not just use “/“ if you’ll get the same answer as “//“
2 Antworten
+ 4
Run this code, you will see differences:
print(8.0/3)
print(8.0//3)
print(8/3)
print(8//3)
+ 3
only in a single scenario '/' and '//' results in same answer when numerator is a multiple of denominator.(remainder = 0)
or if you are using python2.X
Python3.X will give you different results,
and '//' is used when you want to skip the decimal part.
although you can do it by typeconversion,
print ( int(8/3))
print (8//3)
but you can see using '//' is more handy than other method.