Ask Your Question

Revision history [back]

The Python behaviour you describe was that of Python 2, which is no longer current.

In Python 3:

>>> 5 / 3
1.6666666666666667
>>> 5 / 2
2.5
>>> 4 / 2
2.0

In Sage, if you want "floor division" (integer quotient without remainder), use // instead of /.

sage: 5 // 3
1
sage: 5 // 2
2
sage: 4 // 2
2