To complement these other answers, the //
operator also offers significant (3x) performance benefits over /
, presuming you want integer division.
$ python -m timeit '20.5 // 2'
100,000,000 loops, best of 3: 14.9 nsec per loop
$ python -m timeit '20.5 / 2'
10,000,000 loops, best of 3: 48.4 nsec per loop
$ python -m timeit '20 / 2'
10,000,000 loops, best of 3: 43.0 nsec per loop
$ python -m timeit '20 // 2'
100,000,000 loops, best of 3: 14.4 nsec per loop