+ 1

Division vs floor division

Why not just use “/“ if you’ll get the same answer as “//“

3rd Jul 2018, 1:44 PM
Blaine
2 ответов
+ 4
Run this code, you will see differences: print(8.0/3) print(8.0//3) print(8/3) print(8//3)
3rd Jul 2018, 1:57 PM
Paul
Paul - avatar
+ 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.
3rd Jul 2018, 2:45 PM
Nikhil Dhama
Nikhil Dhama - avatar